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): def log_info(self, dct=None):
extra = dct or {} extra = dct or {}
extra.update({ 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_spec': self.task_spec.name,
'task_name': self.task_spec.description, 'task_name': self.task_spec.description,
'task_id': self.id, 'task_id': self.id,

View File

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

View File

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

@ -28,7 +28,7 @@ flask-migrate = "*"
flask-restful = "*" flask-restful = "*"
werkzeug = "*" werkzeug = "*"
SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"} SpiffWorkflow = {git = "https://github.com/sartography/SpiffWorkflow", rev = "main"}
#SpiffWorkflow = {develop = true, path = "../SpiffWorkflow" } # SpiffWorkflow = {develop = true, path = "../SpiffWorkflow" }
sentry-sdk = "^1.10" sentry-sdk = "^1.10"
sphinx-autoapi = "^2.0" sphinx-autoapi = "^2.0"
flask-bpmn = {git = "https://github.com/sartography/flask-bpmn", rev = "main"} flask-bpmn = {git = "https://github.com/sartography/flask-bpmn", rev = "main"}

View File

@ -14,6 +14,7 @@ class SpiffLoggingModel(SpiffworkflowBaseDBModel):
id: int = db.Column(db.Integer, primary_key=True) id: int = db.Column(db.Integer, primary_key=True)
process_instance_id: int = db.Column(db.Integer, nullable=False) process_instance_id: int = db.Column(db.Integer, nullable=False)
bpmn_process_identifier: str = db.Column(db.String(255), 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_identifier: str = db.Column(db.String(255), nullable=False)
bpmn_task_name: str = db.Column(db.String(255), nullable=True) bpmn_task_name: str = db.Column(db.String(255), nullable=True)
bpmn_task_type: 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 # 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 # that initializes a BpmnWorkflow without a process instance
if record and record.process_instance_id: # type: ignore 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 spiff_task_guid = str(record.task_id) # type: ignore
bpmn_task_identifier = str(record.task_spec) # 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 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 "process_instance_id": record.process_instance_id, # type: ignore
"bpmn_process_identifier": bpmn_process_identifier, "bpmn_process_identifier": bpmn_process_identifier,
"bpmn_process_name": bpmn_process_name,
"spiff_task_guid": spiff_task_guid, "spiff_task_guid": spiff_task_guid,
"bpmn_task_name": bpmn_task_name, "bpmn_task_name": bpmn_task_name,
"bpmn_task_identifier": bpmn_task_identifier, "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}`; processInstanceShowPageBaseUrl = `/admin/process-instances/${params.process_model_id}`;
} }
const userEmail = UserService.getUserEmail();
useEffect(() => { useEffect(() => {
const setProcessInstanceLogListFromResult = (result: any) => { const setProcessInstanceLogListFromResult = (result: any) => {
setProcessInstanceLogs(result.results); setProcessInstanceLogs(result.results);
@ -59,11 +57,14 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
(row.bpmn_task_type === 'End Event' ? 'Process Ended' : '')} (row.bpmn_task_type === 'End Event' ? 'Process Ended' : '')}
</td> </td>
); );
const bpmnProcessCell = (
<td>{row.bpmn_process_name || row.bpmn_process_identifier}</td>
);
if (isDetailedView) { if (isDetailedView) {
tableRow.push( tableRow.push(
<> <>
<td data-qa="paginated-entity-id">{row.id}</td> <td data-qa="paginated-entity-id">{row.id}</td>
<td>{row.bpmn_process_identifier}</td> {bpmnProcessCell}
{taskNameCell} {taskNameCell}
</> </>
); );
@ -71,7 +72,7 @@ export default function ProcessInstanceLogList({ variant }: OwnProps) {
tableRow.push( tableRow.push(
<> <>
{taskNameCell} {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.bpmn_task_type}</td>
<td>{row.message}</td> <td>{row.message}</td>
<td>{row.username === userEmail ? 'me 🔥' : row.username}</td> <td>{row.username}</td>
</> </>
); );
} }