Skip to content

Commit

Permalink
average edit column added to report (#394)
Browse files Browse the repository at this point in the history
* average edit column added to report

* only shows column for tasks with edits
  • Loading branch information
vrose99 authored Jan 13, 2023
1 parent 79165a2 commit 39cb222
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion neuvue_project/dashboard/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ def post(self, request, *args, **kwargs):
sieve=sieve,
select=["assignee", "status", "duration", "metadata", "closed", "opened"],
)
task_df['n_operation_ids'] = task_df['metadata'].apply(lambda x: len(x.get('operation_ids')) if isinstance(x.get('operation_ids'), list) else 0)
task_has_edits = True if any(task_df['n_operation_ids'].to_list()) else False

if namespace in decision_namespaces:
import plotly.express as px
Expand Down Expand Up @@ -383,8 +385,10 @@ def post(self, request, *args, **kwargs):
"Username",
"Total Duration (h)",
"Avg Closed Duration (m)",
"Avg Duration (m)",
"Avg Duration (m)"
]
if task_has_edits:
columns.append("Average Edits")
status_states = ["pending", "open", "closed", "errored"]
columns.extend(status_states)
table_rows = []
Expand All @@ -400,6 +404,11 @@ def post(self, request, *args, **kwargs):
)
avg_duration = str(round(assignee_df["duration"].mean() / 60, 2))
user_metrics = [assignee, total_duration, avg_closed_duration, avg_duration]

if task_has_edits:
avg_edits = str(round(assignee_df["n_operation_ids"].mean(), 2))
user_metrics.append(avg_edits)

for status in status_states:
number_of_tasks = len(assignee_df[assignee_df["status"] == status])
user_metrics.append(number_of_tasks)
Expand Down

0 comments on commit 39cb222

Please sign in to comment.