grassrootsgrocery / admin-portal

GNU Affero General Public License v3.0
10 stars 5 forks source link

Add ability to set a static date as TODAY via environment variable #55

Closed mattsahn closed 1 year ago

mattsahn commented 1 year ago

When the main /events/ page loads up, it uses below query to fetch all events today and in the future: https://github.com/grassrootsgrocery/admin-portal/blob/ff798c65d8d524c50d4c653e86c46343339a5a0a/server/routes/events.ts#L135 This makes sense to do in production since we want to show today's event and future ones to the user. However, it creates a problem for developers using a non-live DEV database, since the data is frozen as of a past date. We want developers to be able to run the app as if it is a specific date in the past so that the database entries to not becomes stale and fall out of view.

I think the best way to achieve this would be to have an environment variable called TODAY with a value of the date that you want the app to treat as the current date. So, the env variable would be like below. Not sure if that's the best date format to use, but that's just the idea.

TODAY=2023-02-01

Once this is available, it will be easy for developers to override the date and not worry about the dev data falling out of view. The production deployment will simply not have it and use the "real" date for its queries.

Tagging @hgreenhut since we were discussing this offline in an email. I think this should work since the app isn't using any views, it's just directly querying the airtable for events past a certain date.

zuechai commented 1 year ago

Resolved in PR #61