Skip to content

Commit

Permalink
Merge pull request #173 from PROCOLLAB-github/feature/sort_weeks
Browse files Browse the repository at this point in the history
Sorted weeks response
  • Loading branch information
pavuchara authored Dec 19, 2024
2 parents 2a996d2 + f06b17e commit 377c666
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/courses/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ def get_stats(skill_id: int, profile_id: int, request_user: CustomUser | None =
}
)
statuses = get_rounded_percentage(sum(user_done_task_objects), sum(all_task_objects))

if data:
try:
data.sort(key=lambda x: x["week"])
except KeyError:
pass
stats_of_weeks: list[WeekStatsDict] = get_stats_of_weeks(skill_id, profile_id, available_week, request_user)

new_data = {"progress": statuses, "tasks": data, "stats_of_weeks": stats_of_weeks}
Expand Down Expand Up @@ -102,4 +106,9 @@ def get_stats_of_weeks(
"done_on_time": None,
}
)
if stats_of_weeks:
try:
stats_of_weeks.sort(key=lambda x: x["week"])
except KeyError:
pass
return stats_of_weeks

0 comments on commit 377c666

Please sign in to comment.