Closed rod-glover closed 4 years ago
Can't we just do this from the frontend? In JS, new Date()
returns today's date.
The current month and this year are not necessarily the latest date available in the database. Even if the cron jobs always run as scheduled, there will be a period when the current month is not yet available. OTOH, it may not matter much, but it could be confusing to the user.
True... just thinking that we may want to decouple frontend from backend as much as possible. Could default to current month and roll back a month until you don't get a 404?
I thought of the 404 strategy too, but dismissed it as a bit icky. However, if, as in Python, one considers exception handling as a normal execution path, then this is okay, except it is slow-ish because of the potentially multiple HTTP requests and attendant delays.
I don't really understand "decouple frontend from backend" in this context. Whether we do it via 404-probing or via an explicit endpoint, the frontend is necessarily coupled to the backend for this information. It can come from nowhere else. I still think an explicit endpoint is natural, and nicer than than 404-probing, though I won't insist on it if you disagree strongly.
I don't really understand "decouple frontend from backend" in this context.
Yeah, so maybe "coupled" isn't quite on mark, but the point is that now we need to modify and deploy two things, and the latter depends on the first. Whereas, really, we could just set the default date to current_month - 1
with a single line of code and move on with our lives :) I think the simple path is just fine in this case; we don't need to over-engineer this.
This will require a new API endpoint that returns these values. And suggest it return first available too, so that the year/month selectors can be limited to the actual range available. Need to create issue in weather-anomaly-data-service for this.