openoakland / woeip

A platform for impacted communities to understand their local air quality and advocate for environmental justice.
https://woaq.org
MIT License
29 stars 16 forks source link

395 datepicker data #434

Closed gsehrlich closed 2 years ago

gsehrlich commented 2 years ago

Checklist

Description

Issue: #395

Brief description of solution I'm an experienced developer of individual Python code for scientific applications, but I'm totally new to web development, Javascript, and collaborating on a codebase. Please feel free to offer any guidance, and thanks for bearing with me!

When the page loads, the map menu will now fetch data from the API to get a list of dates with at least one collection. The date is then automatically set to the most recent date with data. In the date picker, the dates with data are highlighted in blue and the dates without data are disabled so that they cannot be clicked.

Questions:

TangoYankee commented 2 years ago

In views.py, is it okay to use queryset.distinct?

For a short term solution, I'm not too concerned. It does bloat the http response. It also pollutes the browser application memory. But, we only make the request once on render. Also, we immediately discard the bloat and the garbage collector should get to it before it causes problems. In the long term, I think there should be a way to access start dates directly. I'll write more about that on the original issue.

I'm not sure how to test the desired behavior of automatically setting the date

Yeah, this is pretty complex. As a rough outline, I would make a mock request that returns a collection on a specific date. Await that response. Then, the data picker should display the start date of that mocked collection.

In index.js, the linter complained that I check location?.state?.date

React dependency arrays can be a nightmare. Your misgiving are warranted. It may cause issues in the future, if the code gets a feature that updates the location for the component. But for now, it's fine the way it is.

In menu.test.js, the linter complained that I wasn't using the data from July 19th

I think the law of diminishing returns is kicking in. It's probably not worth worrying much more about. Perhaps leave a comment providing background info for the next developer?

gsehrlich commented 2 years ago

In views.py, is it okay to use queryset.distinct?

I'll write more about that on the original issue.

Thanks. This was what originally thinking we should do, but I agree that it's a longer-term issue.

I'm not sure how to test the desired behavior of automatically setting the date

Yeah, this is pretty complex. As a rough outline, I would make a mock request that returns a collection on a specific date. Await that response. Then, the data picker should display the start date of that mocked collection.

This is beyond my capacity right now, so I think I'll leave this for a future update. Should I open a new issue for this?