pacificclimate / weather-anomaly-tool

0 stars 0 forks source link

Set the default month/year to the most recently available month/year #52

Closed rod-glover closed 4 years ago

rod-glover commented 6 years ago

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.

jameshiebert commented 6 years ago

Can't we just do this from the frontend? In JS, new Date() returns today's date.

rod-glover commented 6 years ago

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.

jameshiebert commented 6 years ago

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?

rod-glover commented 6 years ago

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.

jameshiebert commented 6 years ago

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.

jameshiebert commented 4 years ago

Just want to "+1" this issue, since the default section values are now two years behind. Need to set them relative to the current date here and possibly here