Merge pull request #163 from sartography/feature/process_name_for_log_list

prefer the bpmn process name over the identifier on the logs list pag…
This commit is contained in:
Kevin Burnett 2023-03-01 14:21:37 -08:00 committed by GitHub
commit dc123892f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 44 additions and 10 deletions

View File

@ -271,7 +271,8 @@ class Task(object, metaclass=DeprecatedMetaTask):
def log_info(self, dct=None):
extra = dct or {}
extra.update({
'workflow': self.workflow.spec.name,
'workflow_spec': self.workflow.spec.name,
'workflow_name': self.workflow.spec.description,
'task_spec': self.task_spec.name,
'task_name': self.task_spec.description,
'task_id': self.id,

View File

@ -83,7 +83,8 @@ class Workflow(object):
def log_info(self, dct=None):
extra = dct or {}
extra.update({
'workflow': self.spec.name,
'workflow_spec': self.spec.name,
'workflow_name': self.spec.description,
'task_spec': '-',
'task_type': None,
'task_id': None,

View File

@ -55,7 +55,7 @@ if [[ "${1:-}" == "clean" ]]; then
fi
tasks="$tasks upgrade"
elif [[ "${1:-}" == "migrate" ]]; then
tasks="$tasks migrate"
tasks="$tasks migrate upgrade"
elif [[ "${1:-}" == "downgrade" ]]; then
tasks="$tasks downgrade"
else

View File

@ -0,0 +1,28 @@
"""empty message
Revision ID: 8930711a75a4
Revises: 7422be14adc4
Create Date: 2023-03-01 16:16:50.446929
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8930711a75a4'
down_revision = '7422be14adc4'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('spiff_logging', sa.Column('bpmn_process_name', sa.String(length=255), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('spiff_logging', 'bpmn_process_name')
# ### end Alembic commands ###

View File

@ -14,6 +14,7 @@ class SpiffLoggingModel(SpiffworkflowBaseDBModel):
id: int = db.Column(db.Integer, primary_key=True)
process_instance_id: int = db.Column(db.Integer, nullable=False)
bpmn_process_identifier: str = db.Column(db.String(255), nullable=False)
bpmn_process_name: Optional[str] = db.Column(db.String(255), nullable=True)
bpmn_task_identifier: str = db.Column(db.String(255), nullable=False)
bpmn_task_name: str = db.Column(db.String(255), nullable=True)
bpmn_task_type: str = db.Column(db.String(255), nullable=True)

View File

@ -212,7 +212,8 @@ class DBHandler(logging.Handler):
# if we do not have a process instance id then do not log and assume we are running a script unit test
# that initializes a BpmnWorkflow without a process instance
if record and record.process_instance_id: # type: ignore
bpmn_process_identifier = record.workflow # type: ignore
bpmn_process_identifier = record.workflow_spec # type: ignore
bpmn_process_name = record.workflow_name # type: ignore
spiff_task_guid = str(record.task_id) # type: ignore
bpmn_task_identifier = str(record.task_spec) # type: ignore
bpmn_task_name = record.task_name if hasattr(record, "task_name") else None # type: ignore
@ -235,6 +236,7 @@ class DBHandler(logging.Handler):
{
"process_instance_id": record.process_instance_id, # type: ignore
"bpmn_process_identifier": bpmn_process_identifier,
"bpmn_process_name": bpmn_process_name,
"spiff_task_guid": spiff_task_guid,
"bpmn_task_name": bpmn_task_name,
"bpmn_task_identifier": bpmn_task_identifier,

View File

@ -29,8 +29,6 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}`;
}
const userEmail = UserService.getUserEmail();
useEffect(() => {
const setProcessInstanceLogListFromResult = (result: any) => {
setProcessInstanceLogs(result.results);
@ -59,11 +57,14 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
(row.bpmn_task_type === 'End Event' ? 'Process Ended' : '')}
</td>
);
const bpmnProcessCell = (
<td>{row.bpmn_process_name || row.bpmn_process_identifier}</td>
);
if (isDetailedView) {
tableRow.push(
<>
<td data-qa="paginated-entity-id">{row.id}</td>
<td>{row.bpmn_process_identifier}</td>
{bpmnProcessCell}
{taskNameCell}
</>
);
@ -71,7 +72,7 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
tableRow.push(
<>
{taskNameCell}
<td>{row.bpmn_process_identifier}</td>
{bpmnProcessCell}
</>
);
}
@ -80,7 +81,7 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
<>
<td>{row.bpmn_task_type}</td>
<td>{row.message}</td>
<td>{row.username === userEmail ? 'me 🔥' : row.username}</td>
<td>{row.username}</td>
</>
);
}