Skip to content

Commit

Permalink
improve method of last-activity
Browse files Browse the repository at this point in the history
  • Loading branch information
madjid-asa committed Oct 2, 2023
1 parent 7c330a0 commit fac4e5d
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions lemarche/siaes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1030,19 +1030,14 @@ def last_activity_at(self):
last_activity_at = None
if self.users.exists():
users_last_activities = self.users.values_list(
"last_login", "updated_at", "dashboard_last_seen_date", "tender_list_last_seen_date"
"updated_at", "last_login", "dashboard_last_seen_date", "tender_list_last_seen_date"
)
for index, user_last_activities in enumerate(users_last_activities):
if index == 0:
# set the first date
last_activity_at = user_last_activities[0]
for index1, activity_at in enumerate(user_last_activities):
if index1 > 0:
last_activity_at = (
activity_at if activity_at and activity_at > last_activity_at else last_activity_at
)
else:
for activity_at in user_last_activities:
start_index = 1 if index == 0 else 0
for _, activity_at in enumerate(user_last_activities, start=start_index):
last_activity_at = (
activity_at if activity_at and activity_at > last_activity_at else last_activity_at
)
Expand Down

0 comments on commit fac4e5d

Please sign in to comment.