Skip to content

Commit 389c885

Browse files
committed
fix some media not appearing in timeline #625
1 parent 37ca97c commit 389c885

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/app/statistics.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,8 @@ def get_timeline(user_media):
323323
for media in queryset:
324324
local_start_date = timezone.localdate(media.start_date)
325325
local_end_date = timezone.localdate(media.end_date)
326-
if local_start_date and local_end_date:
326+
327+
if media.start_date and media.end_date:
327328
# add media to all months between start and end
328329
current_date = local_start_date
329330
while current_date <= local_end_date:
@@ -337,23 +338,22 @@ def get_timeline(user_media):
337338
# Move to next month
338339
current_date += relativedelta(months=1)
339340
current_date = current_date.replace(day=1)
340-
elif local_start_date:
341+
elif media.start_date:
341342
# If only start date, add to the start month
342343
year = local_start_date.year
343344
month = local_start_date.month
344345
month_name = calendar.month_name[month]
345346
month_year = f"{month_name} {year}"
346347

347348
timeline[month_year].append(media)
348-
elif local_end_date:
349+
elif media.end_date:
349350
# If only end date, add to the end month
350351
year = local_end_date.year
351352
month = local_end_date.month
352353
month_name = calendar.month_name[month]
353354
month_year = f"{month_name} {year}"
354355

355356
timeline[month_year].append(media)
356-
357357
# Convert to sorted dictionary with media sorted by start date
358358
# Create a list sorted by year and month in reverse order
359359
sorted_items = []
@@ -371,7 +371,6 @@ def get_timeline(user_media):
371371
for month_year, media_list, _, _ in sorted_items:
372372
# Sort the media list using our custom sort key
373373
result[month_year] = sorted(media_list, key=time_line_sort_key)
374-
375374
return result
376375

377376

0 commit comments

Comments
 (0)