Closed gsehrlich closed 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?
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?
Checklist
docker-compose up -d --build
docker-compose exec api /bin/bash
make validate
ctrl/command+D
orexit
docker-compose exec web /bin/sh
npm run test
ornpx jest
npm run lint-fix
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:
queryset.distinct
? All that's need is a list of distinct dates, but that method includes the unneeded columns of the table too (which isn't very much data). When I tried usingqueryset.values_list
to omit those columns, the serializer threw an error.location?.state?.date
but have no corresponding state variable in the dependency array, so I addedlocation
to it. Is that necessary? It shouldn't change after the page loads, right?setOfDates
. I pacified it by putting all the collections data in a single object. Is there a better way of handling that? Should I omit the data entirely? It's true that it's unneeded, but it feels dangerous to omit it whensetOfDates
has that date.