added username and task_type to logs w/ burnettk cullerton
This commit is contained in:
parent
9202d9ed12
commit
c5dcb39f78
|
@ -1,8 +1,8 @@
|
|||
"""empty message
|
||||
|
||||
Revision ID: 00a59d952198
|
||||
Revision ID: 1ccfcb7baf22
|
||||
Revises:
|
||||
Create Date: 2022-09-19 09:01:56.805355
|
||||
Create Date: 2022-09-21 16:05:59.406883
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '00a59d952198'
|
||||
revision = '1ccfcb7baf22'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
@ -210,6 +210,7 @@ def upgrade():
|
|||
sa.Column('process_instance_id', sa.Integer(), nullable=False),
|
||||
sa.Column('bpmn_process_identifier', sa.String(length=255), nullable=False),
|
||||
sa.Column('bpmn_task_identifier', sa.String(length=255), nullable=False),
|
||||
sa.Column('bpmn_task_type', sa.String(length=255), nullable=True),
|
||||
sa.Column('spiff_task_guid', sa.String(length=50), nullable=False),
|
||||
sa.Column('timestamp', sa.DECIMAL(precision=17, scale=6), nullable=False),
|
||||
sa.Column('message', sa.String(length=255), nullable=True),
|
|
@ -1866,7 +1866,7 @@ pytz = "*"
|
|||
type = "git"
|
||||
url = "https://github.com/sartography/SpiffWorkflow"
|
||||
reference = "main"
|
||||
resolved_reference = "3cb03458017cd78dc6fe63f1c6c5d84e821e523f"
|
||||
resolved_reference = "082d116990fcada49c3287f585cfd3a46c55de0f"
|
||||
|
||||
[[package]]
|
||||
name = "sqlalchemy"
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
import os
|
||||
from typing import Any
|
||||
|
||||
import sqlalchemy
|
||||
|
||||
import connexion # type: ignore
|
||||
import flask.app
|
||||
import flask.json
|
||||
|
@ -29,6 +31,16 @@ class MyJSONEncoder(flask.json.JSONEncoder):
|
|||
"""Default."""
|
||||
if hasattr(obj, "serialized"):
|
||||
return obj.serialized
|
||||
elif isinstance(obj, sqlalchemy.engine.row.Row):
|
||||
return_dict = {}
|
||||
for row_key in obj.keys():
|
||||
row_value = obj[row_key]
|
||||
if (hasattr(row_value, '__dict__')):
|
||||
return_dict.update(row_value.__dict__)
|
||||
else:
|
||||
return_dict.update({ row_key: row_value })
|
||||
return_dict.pop('_sa_instance_state')
|
||||
return return_dict
|
||||
return super().default(obj)
|
||||
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ class SpiffLoggingModel(SpiffworkflowBaseDBModel):
|
|||
process_instance_id: int = db.Column(ForeignKey(ProcessInstanceModel.id), nullable=False) # type: ignore
|
||||
bpmn_process_identifier: str = db.Column(db.String(255), nullable=False)
|
||||
bpmn_task_identifier: str = db.Column(db.String(255), nullable=False)
|
||||
bpmn_task_type: str = db.Column(db.String(255), nullable=True)
|
||||
spiff_task_guid: str = db.Column(db.String(50), nullable=False)
|
||||
timestamp: float = db.Column(db.DECIMAL(17, 6), nullable=False)
|
||||
message: Optional[str] = db.Column(db.String(255), nullable=True)
|
||||
|
|
|
@ -44,6 +44,7 @@ from spiffworkflow_backend.models.process_instance_report import (
|
|||
from spiffworkflow_backend.models.process_model import ProcessModelInfo
|
||||
from spiffworkflow_backend.models.process_model import ProcessModelInfoSchema
|
||||
from spiffworkflow_backend.models.spiff_logging import SpiffLoggingModel
|
||||
from spiffworkflow_backend.models.user import UserModel
|
||||
from spiffworkflow_backend.services.error_handling_service import ErrorHandlingService
|
||||
from spiffworkflow_backend.services.file_system_service import FileSystemService
|
||||
from spiffworkflow_backend.services.message_service import MessageService
|
||||
|
@ -391,6 +392,10 @@ def process_instance_log_list(
|
|||
SpiffLoggingModel.process_instance_id == process_instance.id
|
||||
)
|
||||
.order_by(SpiffLoggingModel.timestamp.desc()) # type: ignore
|
||||
.join(UserModel)
|
||||
.add_columns(
|
||||
UserModel.username,
|
||||
)
|
||||
.paginate(page, per_page, False)
|
||||
)
|
||||
|
||||
|
|
|
@ -215,6 +215,8 @@ def login_return(code: str, state: str, session_state: str) -> Optional[Response
|
|||
name = user_info["name"]
|
||||
if "username" in user_info:
|
||||
username = user_info["username"]
|
||||
elif "preferred_username" in user_info:
|
||||
username = user_info["preferred_username"]
|
||||
if "email" in user_info:
|
||||
email = user_info["email"]
|
||||
user_model = UserService().create_user(
|
||||
|
|
|
@ -176,6 +176,7 @@ class DBHandler(logging.Handler):
|
|||
bpmn_process_identifier = record.workflow # type: ignore
|
||||
spiff_task_guid = str(record.task_id) # type: ignore
|
||||
bpmn_task_identifier = str(record.task_spec) # type: ignore
|
||||
bpmn_task_type = record.task_type # type: ignore
|
||||
timestamp = record.created
|
||||
message = record.msg if hasattr(record, "msg") else None
|
||||
current_user_id = record.current_user_id if hasattr(record, "current_user_id") else None # type: ignore
|
||||
|
@ -184,6 +185,7 @@ class DBHandler(logging.Handler):
|
|||
bpmn_process_identifier=bpmn_process_identifier,
|
||||
spiff_task_guid=spiff_task_guid,
|
||||
bpmn_task_identifier=bpmn_task_identifier,
|
||||
bpmn_task_type=bpmn_task_type,
|
||||
message=message,
|
||||
timestamp=timestamp,
|
||||
current_user_id=current_user_id,
|
||||
|
|
Loading…
Reference in New Issue