backend.api.modules.resource_based_router

Contains the routes for handling resource-based conformance checking.

Attributes

Functions

compute_resource_based_metrics() → Dict[str, str])

Computes the resource-based metrics and stores it.

get_handover_of_work_metric(→ Dict[str, ...)

Returns the handover of work values in table/graph format.

get_subcontracting_metric(→ Dict[str, ...)

Returns the subcontracting values in table/graph format.

get_working_together_metric(→ Dict[str, ...)

Returns the working together metric in table/graph format.

get_similar_activities_metric(→ Dict[str, ...)

Returns the similar activities metric in table/graph format.

get_organizational_roles_result(→ Dict[str, ...)

Retrieves the computed organizational roles and returns them as a table.

get_distinct_activities(, start_time, end_time, celonis)

Retrieves the number of distinct activities.

get_distinct_activities_pql(, start_time, end_time, ...)

Retrieves the number of distinct activities via a pql query.

get_resource_activity_frequency(, activity, ...)

Retrieves the activity frequency for a given resource and activity.

get_resource_activity_frequency_pql(, activity, ...)

Retrieves the activity frequency for an activity via a PQL query.

get_resource_activity_completions(, start_time, ...)

Retrieves the number of activity instances completed by a resource.

get_resource_activity_completions_pql(, start_time, ...)

Retrieves the number of activity instances completed via a PQL query.

get_resource_case_completions(, start_time, end_time, ...)

Retrieves the number of cases completed by a resource.

get_resource_case_completions_pql(, start_time, ...)

Retrieves the number of cases completed by a resource via a PQL query.

get_resource_fraction_case_completions(, start_time, ...)

Retrieves the fraction of cases completed by a resource.

get_resource_fraction_case_completions_pql(, ...)

Retrieves the fraction of cases completed by a resource via a PQL query.

get_resource_average_workload(, start_time, end_time, ...)

Retrieves the average workload for a given resource in a time interval.

get_resource_average_workload_pql(, start_time, ...)

Retrieves the average workload for a resource via a PQL query.

get_resource_multitasking(, start_time, end_time, celonis)

Retrieves the multitasking metric for a given resource.

get_resource_average_activity_duration(, activity, ...)

Retrieves the average duration for an activity completed by a resource.

get_resource_average_case_duration(, start_time, ...)

Retrieves the average duration of cases completed by a resource.

get_interaction_of_two_resources(, resource2, ...)

Retrieves the interaction between two resources.

get_interaction_of_two_resources_pql(, resource2, ...)

Retrieves the interaction between two resources via a PQL query.

get_resource_social_position(, start_time, end_time, ...)

Retrieves the social position of a given resource in a time interval.

get_group_relative_focus_metric(→ Dict[str, ...)

Retrieves the Group Relative Focus metric.

get_group_relative_stake_metric(→ Dict[str, ...)

Retrieves the Group Relative Stake metric.

get_group_coverage_metric(→ Dict[str, List[Dict[str, ...)

Retrieves the Group Coverage metric.

get_group_member_contribution_metric(→ Dict[str, ...)

Retrieves the Group Member Contribution metric formatted as a table.

Module Contents

type backend.api.modules.resource_based_router.TableType = Dict[str, List[str] | List[List[Any]]]
type backend.api.modules.resource_based_router.GraphType = Dict[str, List[Dict[str, Any]]]
backend.api.modules.resource_based_router.router
backend.api.modules.resource_based_router.MODULE_NAME = 'resource_based'
async backend.api.modules.resource_based_router.compute_resource_based_metrics(background_tasks: fastapi.BackgroundTasks, request: fastapi.Request, celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) Dict[str, str]

Computes the resource-based metrics and stores it.

Parameters:
  • background_tasks – The background tasks manager.

  • request – The FastAPI request object.

  • celonis – The Celonis connection manager instance.

Returns:

A dictionary containing the job ID of the scheduled task.

async backend.api.modules.resource_based_router.get_handover_of_work_metric(job_id: str, request: fastapi.Request) Dict[str, List[TableType | GraphType]]

Returns the handover of work values in table/graph format.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A dictionary containing the tables and graphs for the handover of work metric.

async backend.api.modules.resource_based_router.get_subcontracting_metric(job_id: str, request: fastapi.Request) Dict[str, List[TableType | GraphType]]

Returns the subcontracting values in table/graph format.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A dictionary containing the tables and graphs for the subcontracting metric.

async backend.api.modules.resource_based_router.get_working_together_metric(job_id: str, request: fastapi.Request) Dict[str, List[TableType | GraphType]]

Returns the working together metric in table/graph format.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A dictionary containing the tables and graphs for the working together metric.

async backend.api.modules.resource_based_router.get_similar_activities_metric(job_id: str, request: fastapi.Request) Dict[str, List[TableType | GraphType]]

Returns the similar activities metric in table/graph format.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A dictionary containing the tables and graphs for the similar activities metric.

async backend.api.modules.resource_based_router.get_organizational_roles_result(job_id: str, request: fastapi.Request) Dict[str, List[Dict[str, List[Any]]]]

Retrieves the computed organizational roles and returns them as a table.

Parameters:
  • job_id – The ID of the job to retrieve the organizational roles for.

  • request – The FastAPI request object.

Returns:

Headers: [“Activity”, “Originator”, “Importance”]

Return type:

A ResponseSchema object with a table

async backend.api.modules.resource_based_router.get_distinct_activities(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time.'), end_time: str = Query(..., description='End time.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) int

Retrieves the number of distinct activities.

Parameters:
  • start_time – The start time of the range.

  • end_time – The end time of the range.

  • resource – The resource for which to calculate the number of distinct activities.

  • celonis – The Celonis connection manager instance.

Returns:

The number of distinct activities for the specified resource.

async backend.api.modules.resource_based_router.get_distinct_activities_pql(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time.'), end_time: str = Query(..., description='End time.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) int

Retrieves the number of distinct activities via a pql query.

Parameters:
  • start_time – The start time of the range.

  • end_time – The end time of the range.

  • resource – The resource for which to calculate the number of distinct activities.

  • celonis – The Celonis connection manager instance.

Returns:

The number of distinct activities for the specified resource.

async backend.api.modules.resource_based_router.get_resource_activity_frequency(resource: str = Query(..., description='The resource identifier.'), activity: str = Query(..., description='The specific activity name.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the activity frequency for a given resource and activity.

Parameters:
  • resource – The resource for which to calculate the activity frequency.

  • activity – The activity for which to calculate the frequency.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the activity frequency.

async backend.api.modules.resource_based_router.get_resource_activity_frequency_pql(resource: str = Query(..., description='The resource identifier.'), activity: str = Query(..., description='The specific activity name.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the activity frequency for an activity via a PQL query.

Parameters:
  • resource – The resource for which to calculate the activity frequency.

  • activity – The activity for which to calculate the frequency.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the activity frequency.

async backend.api.modules.resource_based_router.get_resource_activity_completions(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) int

Retrieves the number of activity instances completed by a resource.

Parameters:
  • resource – The resource for which to calculate activity completions.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

An integer indicating the number of activity completions.

async backend.api.modules.resource_based_router.get_resource_activity_completions_pql(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) int

Retrieves the number of activity instances completed via a PQL query.

Parameters:
  • resource – The resource for which to calculate activity completions.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

An integer indicating the number of activity completions.

async backend.api.modules.resource_based_router.get_resource_case_completions(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) int

Retrieves the number of cases completed by a resource.

Parameters:
  • resource – The resource for which to calculate case completions.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

An integer indicating the number of case completions involving the resource.

async backend.api.modules.resource_based_router.get_resource_case_completions_pql(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) int

Retrieves the number of cases completed by a resource via a PQL query.

Parameters:
  • resource – The resource for which to calculate case completions.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

An integer indicating the number of case completions involving the resource.

async backend.api.modules.resource_based_router.get_resource_fraction_case_completions(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the fraction of cases completed by a resource.

Parameters:
  • resource – The resource for which to calculate the fraction of case completions.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the fraction of case completions involving the resource.

async backend.api.modules.resource_based_router.get_resource_fraction_case_completions_pql(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the fraction of cases completed by a resource via a PQL query.

Parameters:
  • resource – The resource for which to calculate the fraction of case completions.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the fraction of case completions involving the resource.

async backend.api.modules.resource_based_router.get_resource_average_workload(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the average workload for a given resource in a time interval.

Parameters:
  • resource – The resource for which to calculate the average workload.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the average workload.

async backend.api.modules.resource_based_router.get_resource_average_workload_pql(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the average workload for a resource via a PQL query.

Parameters:
  • resource – The resource for which to calculate the average workload.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the average workload.

async backend.api.modules.resource_based_router.get_resource_multitasking(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the multitasking metric for a given resource.

Parameters:
  • resource – The resource for which to calculate multitasking.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the multitasking metric.

async backend.api.modules.resource_based_router.get_resource_average_activity_duration(resource: str = Query(..., description='The resource identifier.'), activity: str = Query(..., description='The specific activity name.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the average duration for an activity completed by a resource.

Parameters:
  • resource – The resource involved.

  • activity – The activity name.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the average duration of the activity for the resource.

async backend.api.modules.resource_based_router.get_resource_average_case_duration(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the average duration of cases completed by a resource.

Parameters:
  • resource – The resource involved.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the average duration of cases involving the resource.

async backend.api.modules.resource_based_router.get_interaction_of_two_resources(resource1: str = Query(..., description='The first resource identifier.'), resource2: str = Query(..., description='The second resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the interaction between two resources.

Parameters:
  • resource1 – The first resource.

  • resource2 – The second resource.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the interaction (number of common cases) between the two resources.

async backend.api.modules.resource_based_router.get_interaction_of_two_resources_pql(resource1: str = Query(..., description='The first resource identifier.'), resource2: str = Query(..., description='The second resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the interaction between two resources via a PQL query.

Parameters:
  • resource1 – The first resource.

  • resource2 – The second resource.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the interaction (number of common cases) between the two resources.

async backend.api.modules.resource_based_router.get_resource_social_position(resource: str = Query(..., description='The resource identifier.'), start_time: str = Query(..., description='Start time of the interval.'), end_time: str = Query(..., description='End time of the interval.'), celonis: backend.celonis_connection.celonis_connection_manager.CelonisConnectionManager = Depends(get_celonis_connection)) float

Retrieves the social position of a given resource in a time interval.

Parameters:
  • resource – The resource for which to calculate the social position.

  • start_time – The start time of the interval.

  • end_time – The end time of the interval.

  • celonis – The Celonis connection manager instance.

Returns:

A float indicating the social position of the resource.

async backend.api.modules.resource_based_router.get_group_relative_focus_metric(job_id: str, request: fastapi.Request) Dict[str, List[Dict[str, List[Any]]]]

Retrieves the Group Relative Focus metric.

Formatted as a table with headers and rows.

Returns:

ResponseSchema with a single table, no graph.

async backend.api.modules.resource_based_router.get_group_relative_stake_metric(job_id: str, request: fastapi.Request) Dict[str, List[Dict[str, List[Any]]]]

Retrieves the Group Relative Stake metric.

Formatted as a table with headers and rows.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A ResponseSchema containing the Group Relative Stake table.

async backend.api.modules.resource_based_router.get_group_coverage_metric(job_id: str, request: fastapi.Request) Dict[str, List[Dict[str, List[Any]]]]

Retrieves the Group Coverage metric.

Formatted as a table with headers and rows.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A ResponseSchema containing the Group Coverage table.

async backend.api.modules.resource_based_router.get_group_member_contribution_metric(job_id: str, request: fastapi.Request) Dict[str, List[Dict[str, List[Any]]]]

Retrieves the Group Member Contribution metric formatted as a table.

Parameters:
  • job_id – The ID of the job to retrieve the metric for.

  • request – The FastAPI request object.

Returns:

A ResponseSchema containing the Group Member Contribution table.