File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,7 @@ def get_timeline(user_media):
354354 month_year = f"{ month_name } { year } "
355355
356356 timeline [month_year ].append (media )
357+
357358 # Convert to sorted dictionary with media sorted by start date
358359 # Create a list sorted by year and month in reverse order
359360 sorted_items = []
@@ -370,15 +371,15 @@ def get_timeline(user_media):
370371 result = {}
371372 for month_year , media_list , _ , _ in sorted_items :
372373 # Sort the media list using our custom sort key
373- result [month_year ] = sorted (media_list , key = time_line_sort_key )
374+ result [month_year ] = sorted (media_list , key = time_line_sort_key , reverse = True )
374375 return result
375376
376377
377378def time_line_sort_key (media ):
378379 """Sort media items in the timeline."""
379- if media .start_date is not None :
380- return timezone .localdate (media .start_date )
381- return timezone .localdate (media .end_date )
380+ if media .end_date is not None :
381+ return timezone .localdate (media .end_date )
382+ return timezone .localdate (media .start_date )
382383
383384
384385def get_activity_data (user , start_date , end_date ):
You can’t perform that action at this time.
0 commit comments