mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-01-31 04:05:01 +00:00
lint fixes w/ burnettk
This commit is contained in:
parent
ec0cf198d0
commit
bb1642c458
@ -5,15 +5,17 @@ from bowler.types import Leaf
|
|||||||
# actually found unused stuff, and I wanted to remove it.
|
# actually found unused stuff, and I wanted to remove it.
|
||||||
# See also https://github.com/craigds/decrapify
|
# See also https://github.com/craigds/decrapify
|
||||||
|
|
||||||
def remove_function(filename: str, function_name: str) -> None:
|
|
||||||
|
|
||||||
|
def remove_function(filename: str, function_name: str) -> None:
|
||||||
def remove_statement(node, capture, filename):
|
def remove_statement(node, capture, filename):
|
||||||
node.remove()
|
node.remove()
|
||||||
|
|
||||||
bowler_query = (Query(filename)
|
bowler_query = (
|
||||||
|
Query(filename)
|
||||||
.select_function(function_name)
|
.select_function(function_name)
|
||||||
.modify(remove_statement)
|
.modify(remove_statement)
|
||||||
.execute(write=True, silent=True, interactive=False))
|
.execute(write=True, silent=True, interactive=False)
|
||||||
|
)
|
||||||
|
|
||||||
if len(bowler_query.exceptions) > 0:
|
if len(bowler_query.exceptions) > 0:
|
||||||
print(f"Failed to remove function {function_name} from {filename}.")
|
print(f"Failed to remove function {function_name} from {filename}.")
|
||||||
|
@ -11,6 +11,8 @@ from spiffworkflow_backend.services.process_instance_processor import (
|
|||||||
from spiffworkflow_backend.services.process_instance_service import (
|
from spiffworkflow_backend.services.process_instance_service import (
|
||||||
ProcessInstanceService,
|
ProcessInstanceService,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main."""
|
"""Main."""
|
||||||
app = get_hacked_up_app_for_script()
|
app = get_hacked_up_app_for_script()
|
||||||
|
@ -231,7 +231,9 @@ def process_instance_list_for_me(
|
|||||||
page: int = 1,
|
page: int = 1,
|
||||||
per_page: int = 100,
|
per_page: int = 100,
|
||||||
) -> flask.wrappers.Response:
|
) -> flask.wrappers.Response:
|
||||||
ProcessInstanceReportService.add_or_update_filter(body['report_metadata']['filter_by'], {"field_name": 'with_relation_to_me', "field_value": True})
|
ProcessInstanceReportService.add_or_update_filter(
|
||||||
|
body["report_metadata"]["filter_by"], {"field_name": "with_relation_to_me", "field_value": True}
|
||||||
|
)
|
||||||
return process_instance_list(
|
return process_instance_list(
|
||||||
process_model_identifier=process_model_identifier,
|
process_model_identifier=process_model_identifier,
|
||||||
page=page,
|
page=page,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
"""Process_instance_report_service."""
|
"""Process_instance_report_service."""
|
||||||
import re
|
|
||||||
import copy
|
import copy
|
||||||
|
import re
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Generator
|
from typing import Generator
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
@ -43,9 +43,9 @@ class ProcessInstanceReportService:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def system_metadata_map(cls, metadata_key: str) -> Optional[ReportMetadata]:
|
def system_metadata_map(cls, metadata_key: str) -> Optional[ReportMetadata]:
|
||||||
# TODO replace with system reports that are loaded on launch (or similar)
|
# TODO replace with system reports that are loaded on launch (or similar)
|
||||||
terminal_status_values = ','.join(ProcessInstanceModel.terminal_statuses())
|
terminal_status_values = ",".join(ProcessInstanceModel.terminal_statuses())
|
||||||
non_terminal_status_values = ','.join(ProcessInstanceModel.non_terminal_statuses())
|
non_terminal_status_values = ",".join(ProcessInstanceModel.non_terminal_statuses())
|
||||||
active_status_values = ','.join(ProcessInstanceModel.active_statuses())
|
active_status_values = ",".join(ProcessInstanceModel.active_statuses())
|
||||||
default: ReportMetadata = {
|
default: ReportMetadata = {
|
||||||
"columns": cls.builtin_column_options(),
|
"columns": cls.builtin_column_options(),
|
||||||
"filter_by": [],
|
"filter_by": [],
|
||||||
@ -174,14 +174,14 @@ class ProcessInstanceReportService:
|
|||||||
@classmethod
|
@classmethod
|
||||||
def compile_report(cls, report_metadata: ReportMetadata, user: UserModel) -> None:
|
def compile_report(cls, report_metadata: ReportMetadata, user: UserModel) -> None:
|
||||||
compiled_filters: list[FilterValue] = []
|
compiled_filters: list[FilterValue] = []
|
||||||
old_filters = copy.deepcopy(report_metadata['filter_by'])
|
old_filters = copy.deepcopy(report_metadata["filter_by"])
|
||||||
for filter in old_filters:
|
for filter in old_filters:
|
||||||
if filter['field_name'] == 'initiated_by_me':
|
if filter["field_name"] == "initiated_by_me":
|
||||||
compiled_filters.append({'field_name': 'process_initiator_username', 'field_value': user.username})
|
compiled_filters.append({"field_name": "process_initiator_username", "field_value": user.username})
|
||||||
else:
|
else:
|
||||||
compiled_filters.append(filter)
|
compiled_filters.append(filter)
|
||||||
|
|
||||||
report_metadata['filter_by'] = compiled_filters
|
report_metadata["filter_by"] = compiled_filters
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def report_with_identifier(
|
def report_with_identifier(
|
||||||
@ -243,10 +243,14 @@ class ProcessInstanceReportService:
|
|||||||
return results
|
return results
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def add_human_task_fields(
|
def add_human_task_fields(cls, process_instance_dicts: list[dict]) -> list[dict]:
|
||||||
cls, process_instance_dicts: list[dict]
|
fields_to_return = [
|
||||||
) -> list[dict]:
|
"task_id",
|
||||||
fields_to_return = ["task_id", "task_title", "task_name", "potential_owner_usernames", "assigned_user_group_identifier"]
|
"task_title",
|
||||||
|
"task_name",
|
||||||
|
"potential_owner_usernames",
|
||||||
|
"assigned_user_group_identifier",
|
||||||
|
]
|
||||||
for process_instance_dict in process_instance_dicts:
|
for process_instance_dict in process_instance_dicts:
|
||||||
assigned_user = aliased(UserModel)
|
assigned_user = aliased(UserModel)
|
||||||
human_task_query = (
|
human_task_query = (
|
||||||
@ -341,13 +345,12 @@ class ProcessInstanceReportService:
|
|||||||
def add_or_update_filter(cls, filters: list[FilterValue], new_filter: FilterValue) -> None:
|
def add_or_update_filter(cls, filters: list[FilterValue], new_filter: FilterValue) -> None:
|
||||||
filter_found = False
|
filter_found = False
|
||||||
for filter in filters:
|
for filter in filters:
|
||||||
if filter["field_name"] == new_filter['field_name']:
|
if filter["field_name"] == new_filter["field_name"]:
|
||||||
filter['field_value'] = new_filter['field_value']
|
filter["field_value"] = new_filter["field_value"]
|
||||||
filter_found = True
|
filter_found = True
|
||||||
if filter_found is False:
|
if filter_found is False:
|
||||||
filters.append(new_filter)
|
filters.append(new_filter)
|
||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run_process_instance_report(
|
def run_process_instance_report(
|
||||||
cls,
|
cls,
|
||||||
@ -392,12 +395,6 @@ class ProcessInstanceReportService:
|
|||||||
ProcessInstanceModel.status.in_(process_status.split(",")) # type: ignore
|
ProcessInstanceModel.status.in_(process_status.split(",")) # type: ignore
|
||||||
)
|
)
|
||||||
|
|
||||||
for _value in cls.check_filter_value(filters, "initiated_by_me"):
|
|
||||||
raise Exception("DEPRECATED: initiated_by_me")
|
|
||||||
|
|
||||||
for value in cls.check_filter_value(filters, "has_terminal_status"):
|
|
||||||
raise Exception("DEPRECATED: has_terminal_status")
|
|
||||||
|
|
||||||
has_active_status = cls.get_filter_value(filters, "has_active_status")
|
has_active_status = cls.get_filter_value(filters, "has_active_status")
|
||||||
if has_active_status:
|
if has_active_status:
|
||||||
process_instance_query = process_instance_query.filter(
|
process_instance_query = process_instance_query.filter(
|
||||||
@ -461,7 +458,7 @@ class ProcessInstanceReportService:
|
|||||||
and_(
|
and_(
|
||||||
HumanTaskModel.process_instance_id == ProcessInstanceModel.id,
|
HumanTaskModel.process_instance_id == ProcessInstanceModel.id,
|
||||||
HumanTaskModel.lane_assignment_id.is_(None), # type: ignore
|
HumanTaskModel.lane_assignment_id.is_(None), # type: ignore
|
||||||
HumanTaskModel.completed.is_(False) # type: ignore
|
HumanTaskModel.completed.is_(False), # type: ignore
|
||||||
),
|
),
|
||||||
).join(
|
).join(
|
||||||
HumanTaskUserModel,
|
HumanTaskUserModel,
|
||||||
@ -475,7 +472,9 @@ class ProcessInstanceReportService:
|
|||||||
|
|
||||||
process_instance_query = process_instance_query.join(HumanTaskModel)
|
process_instance_query = process_instance_query.join(HumanTaskModel)
|
||||||
if process_status is not None:
|
if process_status is not None:
|
||||||
non_active_statuses = [s for s in process_status.split(',') if s not in ProcessInstanceModel.active_statuses()]
|
non_active_statuses = [
|
||||||
|
s for s in process_status.split(",") if s not in ProcessInstanceModel.active_statuses()
|
||||||
|
]
|
||||||
if len(non_active_statuses) == 0:
|
if len(non_active_statuses) == 0:
|
||||||
process_instance_query = process_instance_query.filter(
|
process_instance_query = process_instance_query.filter(
|
||||||
HumanTaskModel.completed.is_(False) # type: ignore
|
HumanTaskModel.completed.is_(False) # type: ignore
|
||||||
@ -545,7 +544,7 @@ class ProcessInstanceReportService:
|
|||||||
if value is True:
|
if value is True:
|
||||||
results = cls.add_human_task_fields(results)
|
results = cls.add_human_task_fields(results)
|
||||||
|
|
||||||
report_metadata['filter_by'] = filters
|
report_metadata["filter_by"] = filters
|
||||||
response_json = {
|
response_json = {
|
||||||
"report_metadata": report_metadata,
|
"report_metadata": report_metadata,
|
||||||
"results": results,
|
"results": results,
|
||||||
|
@ -5,7 +5,7 @@ import React, {
|
|||||||
useRef,
|
useRef,
|
||||||
useState,
|
useState,
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import { useNavigate, useParams, useSearchParams } from 'react-router-dom';
|
import { useNavigate, useSearchParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { Close, AddAlt, ArrowRight } from '@carbon/icons-react';
|
import { Close, AddAlt, ArrowRight } from '@carbon/icons-react';
|
||||||
import {
|
import {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user