restrict to specific user if querying for instances with tasks waiting for me w/ burnettk (#372)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
7c3c3af057
commit
5ffb3e5ae5
|
@ -244,7 +244,9 @@ class ProcessInstanceReportService:
|
|||
return results
|
||||
|
||||
@classmethod
|
||||
def add_human_task_fields(cls, process_instance_dicts: list[dict]) -> list[dict]:
|
||||
def add_human_task_fields(
|
||||
cls, process_instance_dicts: list[dict], restrict_human_tasks_to_user: UserModel | None = None
|
||||
) -> list[dict]:
|
||||
fields_to_return = [
|
||||
"task_id",
|
||||
"task_title",
|
||||
|
@ -264,6 +266,10 @@ class ProcessInstanceReportService:
|
|||
.outerjoin(assigned_user, assigned_user.id == HumanTaskUserModel.user_id)
|
||||
.outerjoin(GroupModel, GroupModel.id == HumanTaskModel.lane_assignment_id)
|
||||
)
|
||||
if restrict_human_tasks_to_user is not None:
|
||||
human_task_query = human_task_query.filter(
|
||||
HumanTaskUserModel.user_id == restrict_human_tasks_to_user.id
|
||||
)
|
||||
potential_owner_usernames_from_group_concat_or_similar = cls._get_potential_owner_usernames(assigned_user)
|
||||
human_task = (
|
||||
human_task_query.add_columns(
|
||||
|
@ -371,6 +377,7 @@ class ProcessInstanceReportService:
|
|||
# Always join that hot user table for good performance at serialization time.
|
||||
process_instance_query = process_instance_query.options(selectinload(ProcessInstanceModel.process_initiator))
|
||||
filters = report_metadata["filter_by"]
|
||||
restrict_human_tasks_to_user = None
|
||||
|
||||
for value in cls.check_filter_value(filters, "process_model_identifier"):
|
||||
process_model = ProcessModelService.get_process_model(
|
||||
|
@ -483,6 +490,7 @@ class ProcessInstanceReportService:
|
|||
and_(HumanTaskUserModel.human_task_id == HumanTaskModel.id, HumanTaskUserModel.user_id == user.id),
|
||||
)
|
||||
human_task_already_joined = True
|
||||
restrict_human_tasks_to_user = user
|
||||
|
||||
if user_group_identifier is not None:
|
||||
group_model_join_conditions = [GroupModel.id == HumanTaskModel.lane_assignment_id]
|
||||
|
@ -573,7 +581,7 @@ class ProcessInstanceReportService:
|
|||
|
||||
for value in cls.check_filter_value(filters, "with_oldest_open_task"):
|
||||
if value is True:
|
||||
results = cls.add_human_task_fields(results)
|
||||
results = cls.add_human_task_fields(results, restrict_human_tasks_to_user=restrict_human_tasks_to_user)
|
||||
|
||||
report_metadata["filter_by"] = filters
|
||||
response_json = {
|
||||
|
|
Loading…
Reference in New Issue