From fac4e5d1e22390dcfc36e3150e14a2dbb4245601 Mon Sep 17 00:00:00 2001 From: "madjid.asa" Date: Mon, 2 Oct 2023 12:38:27 +0200 Subject: [PATCH] improve method of last-activity --- lemarche/siaes/models.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lemarche/siaes/models.py b/lemarche/siaes/models.py index 88fe34b69..cc7e3f23f 100644 --- a/lemarche/siaes/models.py +++ b/lemarche/siaes/models.py @@ -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 )