Stable last updated time for human tasks with timers (#231)

This commit is contained in:
jbirddog 2023-05-01 10:32:19 -04:00 committed by GitHub
parent 1ea36658cc
commit e9827d0d5e
5 changed files with 46 additions and 3 deletions

View File

@ -0,0 +1,32 @@
"""empty message
Revision ID: 664bb2f00694
Revises: 0c7428378d6e
Create Date: 2023-04-27 13:32:04.143969
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '664bb2f00694'
down_revision = '0c7428378d6e'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('process_instance', schema=None) as batch_op:
batch_op.add_column(sa.Column('task_updated_at_in_seconds', sa.Integer(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('process_instance', schema=None) as batch_op:
batch_op.drop_column('task_updated_at_in_seconds')
# ### end Alembic commands ###

View File

@ -95,6 +95,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
start_in_seconds: int | None = db.Column(db.Integer, index=True)
end_in_seconds: int | None = db.Column(db.Integer, index=True)
task_updated_at_in_seconds: int = db.Column(db.Integer, nullable=True)
updated_at_in_seconds: int = db.Column(db.Integer)
created_at_in_seconds: int = db.Column(db.Integer)
status: str = db.Column(db.String(50), index=True)
@ -122,6 +123,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
"bpmn_version_control_identifier": self.bpmn_version_control_identifier,
"bpmn_version_control_type": self.bpmn_version_control_type,
"process_initiator_username": self.process_initiator.username,
"task_updated_at_in_seconds": self.task_updated_at_in_seconds,
}
def serialized_with_metadata(self) -> dict[str, Any]:

View File

@ -161,7 +161,7 @@ class ProcessInstanceReportService:
{"Header": "Task", "accessor": "task_title"},
{"Header": "Waiting For", "accessor": "waiting_for"},
{"Header": "Started", "accessor": "start_in_seconds"},
{"Header": "Last Updated", "accessor": "updated_at_in_seconds"},
{"Header": "Last Updated", "accessor": "task_updated_at_in_seconds"},
{"Header": "status", "accessor": "status"},
],
"filter_by": [
@ -186,7 +186,7 @@ class ProcessInstanceReportService:
{"Header": "Task", "accessor": "task_title"},
{"Header": "Started By", "accessor": "process_initiator_username"},
{"Header": "Started", "accessor": "start_in_seconds"},
{"Header": "Last Updated", "accessor": "updated_at_in_seconds"},
{"Header": "Last Updated", "accessor": "task_updated_at_in_seconds"},
],
"filter_by": [
{"field_name": "with_tasks_i_can_complete", "field_value": "true"},
@ -208,7 +208,7 @@ class ProcessInstanceReportService:
{"Header": "Task", "accessor": "task_title"},
{"Header": "Started By", "accessor": "process_initiator_username"},
{"Header": "Started", "accessor": "start_in_seconds"},
{"Header": "Last Updated", "accessor": "updated_at_in_seconds"},
{"Header": "Last Updated", "accessor": "task_updated_at_in_seconds"},
],
"filter_by": [
{

View File

@ -157,6 +157,7 @@ class TaskModelSavingDelegate(EngineStepDelegate):
# # self._add_parents(spiff_task)
self.last_completed_spiff_task = spiff_task
self.process_instance.task_updated_at_in_seconds = round(time.time())
if self.secondary_engine_step_delegate:
self.secondary_engine_step_delegate.did_complete_task(spiff_task)

View File

@ -1375,6 +1375,7 @@ export default function ProcessInstanceListTable({
start_in_seconds: formatSecondsForDisplay,
end_in_seconds: formatSecondsForDisplay,
updated_at_in_seconds: formatSecondsForDisplay,
task_updated_at_in_seconds: formatSecondsForDisplay,
};
const formatter =
reportColumnFormatters[column.accessor] ?? defaultFormatter;
@ -1400,6 +1401,13 @@ export default function ProcessInstanceListTable({
/>
);
}
if (column.accessor === 'task_updated_at_in_seconds') {
return (
<TableCellWithTimeAgoInWords
timeInSeconds={row.task_updated_at_in_seconds}
/>
);
}
return (
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions
<td data-qa={`process-instance-show-link-${column.accessor}`}>