spiff-arena/spiffworkflow-backend/bin/last_pi_milestone_query
Kevin Burnett 7de0d97303 Feature/better subworkflow management part 2 (#341)
* Revert "Revert "Feature/better subworkflow management (#331)""

This reverts commit 48dcde8faf00241201c515b54444fe9fb373c7f4.

* updated SpiffWorkflow to fix infinite loop in task trace w/ burnettk

---------

Co-authored-by: burnettk <burnettk@users.noreply.github.com>
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
2023-06-20 10:37:49 -04:00

33 lines
1018 B
Bash
Executable File

#!/usr/bin/env bash
function error_handler() {
>&2 echo "Exited with BAD EXIT CODE '${2}' in ${0} script at line: ${1}."
exit "$2"
}
trap 'error_handler ${LINENO} $?' ERR
set -o errtrace -o errexit -o nounset -o pipefail
mysql -uroot spiffworkflow_backend_local_development -e '
SELECT td.bpmn_identifier FROM process_instance p
JOIN process_instance_event pie ON pie.process_instance_id = p.id
JOIN task t ON t.guid = pie.task_guid
JOIN task_definition td ON td.id = t.task_definition_id
JOIN (
SELECT max(pie.id) as max_pie_id
FROM process_instance_event pie
JOIN task t ON t.guid = pie.task_guid
JOIN task_definition td ON td.id = t.task_definition_id
JOIN bpmn_process bp ON bp.id = t.bpmn_process_id
WHERE td.typename = "IntermediateThrowEvent" OR (bp.direct_parent_process_id is NULL AND td.typename IN ("SimpleBpmnTask", "BpmnStartTask"))
GROUP BY pie.process_instance_id
) AS max_pie ON max_pie.max_pie_id = pie.id
WHERE pie.process_instance_id = 27
;
'