Skip to content

Commit

Permalink
Merge branch 'develop' of https://git.cystack.org/locker/api-core int…
Browse files Browse the repository at this point in the history
…o develop
  • Loading branch information
phuongntt-cystack committed Mar 27, 2024
2 parents 1058476 + 96af121 commit 6b68043
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions locker_server/api_orm/repositories/user_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,8 +589,10 @@ def statistic_dashboard(self, **filters) -> Dict:
)
statistic_device = duration_init_data.get("duration_init") or {}
query = duration_init_data.get("query")
users_by_duration = device_users_orm.filter(creation_date__gte=register_from_param,
creation_date__lte=register_to_param).annotate(
users_by_duration = device_users_orm.filter(
creation_date__gte=register_from_param,
creation_date__lte=register_to_param
).annotate(
duration=RawSQL(query, [], output_field=CharField())
).order_by().values('duration').annotate(count=Count('duration'))
for user_by_duration in users_by_duration:
Expand All @@ -602,6 +604,7 @@ def statistic_dashboard(self, **filters) -> Dict:

result = {
"total_device": device_users_orm.count(),
"total_device_user": device_users_orm.values('user_id').distinct().count(),
"device": statistic_device
}
return result
Expand Down

0 comments on commit 6b68043

Please sign in to comment.