Add flag to indicate if user filtered

This commit is contained in:
Jon Herron 2022-11-16 15:02:33 -05:00
parent 1584f52a18
commit 3bace7d59b
3 changed files with 37 additions and 10 deletions

View File

@ -439,6 +439,12 @@ paths:
description: For filtering - not_started, user_input_required, waiting, complete, error, or suspended
schema:
type: string
- name: user_filter
in: query
required: false
description: For filtering - indicates the user has manually entered a query
schema:
type: boolean
# process_instance_list
get:
operationId: spiffworkflow_backend.routes.process_api_blueprint.process_instance_list

View File

@ -74,6 +74,7 @@ from spiffworkflow_backend.services.process_instance_processor import (
)
from spiffworkflow_backend.services.process_instance_report_service import (
ProcessInstanceReportService,
ProcessInstanceReportFilter,
)
from spiffworkflow_backend.services.process_instance_service import (
ProcessInstanceService,
@ -732,18 +733,32 @@ def process_instance_list(
end_from: Optional[int] = None,
end_to: Optional[int] = None,
process_status: Optional[str] = None,
user_filter: Optional[bool] = False,
) -> flask.wrappers.Response:
"""Process_instance_list."""
process_instance_report = ProcessInstanceReportModel.default_report(g.user)
report_filter = ProcessInstanceReportService.filter_from_metadata_with_overrides(
process_instance_report,
process_model_identifier,
start_from,
start_to,
end_from,
end_to,
process_status,
)
print(f"user_filter: {user_filter}")
if user_filter:
report_filter = ProcessInstanceReportFilter(
process_model_identifier,
start_from,
start_to,
end_from,
end_to,
process_status,
)
else:
report_filter = ProcessInstanceReportService.filter_from_metadata_with_overrides(
process_instance_report,
process_model_identifier,
start_from,
start_to,
end_from,
end_to,
process_status,
)
# process_model_identifier = un_modify_modified_process_model_id(modified_process_model_identifier)
process_instance_query = ProcessInstanceModel.query

View File

@ -125,6 +125,11 @@ export default function ProcessInstanceListTable({
}
let queryParamString = `per_page=${perPage}&page=${page}`;
const userAppliedFilter = searchParams.get('user_filter');
if (userAppliedFilter) {
queryParamString += `&user_filter=${userAppliedFilter}`;
}
Object.keys(parametersToAlwaysFilterBy).forEach((paramName: string) => {
// @ts-expect-error TS(7053) FIXME:
const functionToCall = parametersToAlwaysFilterBy[paramName];
@ -286,7 +291,7 @@ export default function ProcessInstanceListTable({
undefined,
paginationQueryParamPrefix
);
let queryParamString = `per_page=${perPage}&page=${page}`;
let queryParamString = `per_page=${perPage}&page=${page}&user_filter=true`;
const startFromSeconds = convertDateStringToSeconds(startFrom);
const endFromSeconds = convertDateStringToSeconds(endFrom);
@ -338,6 +343,7 @@ export default function ProcessInstanceListTable({
}
setErrorMessage(null);
console.log(queryParamString);
navigate(`/admin/process-instances?${queryParamString}`);
};