Skip to content

🐛 Fix: allday events not displaying if start-end date is start of week #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from

Conversation

that-one-arab
Copy link
Contributor

@that-one-arab that-one-arab commented May 21, 2025

Description

Closes #428

Any all day event that is created at the start of the week (regardless of whether it was created on 2025-05-18 or not) is not displayed upon refreshing page.

Context

We fire a single API request that returns both grid events and allday events in one go.

The API request that is fired sends a start and end parameters to specify the date range for the returned events. These parameters are an ISO 8601 date strings.

Timed events are stored as ISO 8601 date strings.

While all-day events are stored as raw date strings (YYYY-MM-DD)

Problem

If we have the following scenario:

  • Start of the week is 2025-02-02
    • This means that the start and end parameters fired would be 2025-02-02T00:00:00+03:00 and 2025-02-08T23:59:59+03:00 (remember, we send them as ISO 8601 strings)
  • We have a timed event who's start date is 2025-02-02T00:00:00+03:00
  • We have an all-day event who's start date is 2025-02-02

The result would be:

  • The timed event is returned, because timed event's start date 2025-02-02T00:00:00+03:00 can be lexicographically compared to the provided ISO 8601 date string
  • The all-day event is not returned, because all-day event's start date 2025-02-02 cannot lexicographically compared to the provided ISO 8601 date string.

Solution

  • On the frontend side: ensure submitted dates conform to ISO 8601 standards. This will standardize saved event dates in the DB
  • On the backend side: migrate event dates that do not conform to ISO 8601 standards to dates that do conform (we achieve that by inferring the timezone from previously saved timed events, if no timed events exist, we assign a default timezone (this is the only downside of this approach, but I believe it is necessary and should cause only minimal harm)), fix few tests.

We need to run migrate-allday-events on staging and prod once for each env after merging this PR.

This helps with cases where the incoming date filter is malformed or invalid.

One common case is where a timezone string is sent over HTTP. The timezone string contains a "+" character which is a special character and is replaced with a space, this character needs to be encoded before sent over HTTP. If we receive a non-encoded timezone date string, we need to catch it here, or we would have issues with filtering.
Since we now validate incoming dates in the `getReadAllFilter`, this change thankfully caught a failing test, test is now fixed.
Updated the event API to encode the start and end date parameters in the request URL, ensuring proper handling of special characters and preventing potential issues with malformed date strings.
Updated the event preparation logic to convert start and end dates of all-day events to ISO 8601 format using toUTCOffset, since events are not always ISO8601
…onversion to ISO 8601

This script migrates all-day event start and end dates in the database to ISO 8601 format, addressing inconsistencies caused by mixed date formats. It includes logging utilities and handles timezone detection based on existing timed events.
Modified start and end dates for all-day events across multiple mock files to ensure they conform to ISO 8601 format. This change addresses inconsistencies in date handling
@that-one-arab that-one-arab marked this pull request as ready for review May 23, 2025 16:57
@that-one-arab that-one-arab requested a review from tyler-dane May 23, 2025 16:57
@tyler-dane
Copy link
Contributor

What about the sync code? Since we're now diverging from the way gcal tracks all-day events of yyyy-mm-dd for all-day events. https://developers.google.com/workspace/calendar/api/v3/reference/events

This wouuld affect the mappers as well.

Overall, I'm concerned that there are some downstream bugs that'll arise from this in it's current state

@that-one-arab
Copy link
Contributor Author

What about the sync code? Since we're now diverging from the way gcal tracks all-day events of yyyy-mm-dd for all-day events. https://developers.google.com/workspace/calendar/api/v3/reference/events

This wouuld affect the mappers as well.

Overall, I'm concerned that there are some downstream bugs that'll arise from this in it's current state

I didn't get the opportunity to read the sync code yet, I am assuming we also need to explicitly handle how compass retrieves all day events from google calendar there as well.

I'm not sure the level of changes required to make this work, but since you are more familiar on how the sync code works, I will make the assumption that the changes are not small.

If that's the case, I'll continue researching and experimenting with different solutions that don't involve changing the DB model.

@tyler-dane
Copy link
Contributor

Ok. If you don't find an easy fix that you can do on the frontend, let's leave the bug until we get a backend engineer. Changing the frontend, DB model, and backend all in one PR without accounting for all the downstream affects is a recipe for pain.

@tyler-dane
Copy link
Contributor

Closing after deciding to tackle problem in a different way (see #428 )

@tyler-dane tyler-dane closed this May 26, 2025
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.

Creating an all day event at the start of the week does not display it after refreshing the page
2 participants