Skip to content

fix(enrichment): default to next week on weekends#1899

Open
ZamanZahid wants to merge 1 commit into
tjcsl:devfrom
ZamanZahid:fix-enrichment-final
Open

fix(enrichment): default to next week on weekends#1899
ZamanZahid wants to merge 1 commit into
tjcsl:devfrom
ZamanZahid:fix-enrichment-final

Conversation

@ZamanZahid

Copy link
Copy Markdown

Proposed changes

  • Added a helper function for the default enrichment date
  • Updated enrichment_ context to use the new logic
  • Show next week's enrichments on weekends if there are no enrichments left that weekend

Brief description of rationale

Right now, the enrichment page shows the previous week on Saturdays and Sundays even though signups are closed after Friday. This changde makes it show the next week instead unless there is something happeningg that weekend.

@coveralls

coveralls commented May 12, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 79.227% (-0.03%) from 79.252% — ZamanZahid:fix-enrichment-final into tjcsl:dev

@aarushtools aarushtools left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Zaman,

Thank you for the PR, can you look at my comments and implement them? Let me know if you have any questions

Comment thread intranet/apps/enrichment/views.py Outdated
Comment on lines +47 to +48
if timezone.is_naive(weekend_start):
weekend_start = timezone.make_aware(weekend_start)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this necessary? aren't we using django utils timezone. I could be wrong

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable is also misleading in name - it's only the weekend start when the day is the first day of the weekend right?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your right, I removed the unnecessary timezone check, and also renamed the variable to make it more clear for what it is.

Comment on lines +52 to +55
weekend_enrichments = EnrichmentActivity.objects.visible_to_user(request.user).filter(
time__gte=weekend_start,
time__lt=weekend_end,
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A nitpick but I prefer time__range for consistency - it's what is already being used throughout the files (unless you don't want inclusive bounds)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright I Changed this to use time__range for consistency.

Comment thread intranet/apps/enrichment/views.py Outdated
weekend_end = weekend_start + timedelta(days=(8 - local_time.isoweekday()))

weekend_enrichments = EnrichmentActivity.objects.visible_to_user(request.user).filter(
time__gte=weekend_start,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just use local time + timedelta for weekend_start, why is it starting from midnight?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it so weekend_start uses local_time + timedelta rather than starting from midnight.

Comment thread intranet/apps/enrichment/views.py Outdated
if weekend_enrichments.exists():
return local_time

return local_time + timedelta(days=(8 - local_time.isoweekday()))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

save the timedelta as a variable that is well named so it's clear what it's doing, esp. because you repeat this line twice

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Saved the timedelta in a variable so it is not repeated.



def enrichment_context(request, date=None):
def get_default_enrichment_date(request):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docstrings - what is this function doing?

@ZamanZahid ZamanZahid May 17, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a it but, this returns next week's date on weekends unless enrichments still are happening the same weekend.

@ZamanZahid ZamanZahid force-pushed the fix-enrichment-final branch 3 times, most recently from f0e0b04 to f748d25 Compare May 17, 2026 03:46
@ZamanZahid ZamanZahid force-pushed the fix-enrichment-final branch from 42378e9 to 04290af Compare May 17, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants