cdp-backend icon indicating copy to clipboard operation
cdp-backend copied to clipboard

Add vote datetime to `vote` DB model

Open tohuynh opened this issue 3 years ago • 3 comments

Feature Description

A clear and concise description of the feature you're requesting. Add vote datetime field to the vote DB model https://github.com/CouncilDataProject/cdp-backend/blob/main/cdp_backend/database/models.py#L698

Use Case

Please provide a use case to help us understand your request in context. The front end wants to be able to sort a person's voting record by vote datetime.

Solution

Please describe your ideal solution.

Alternatives

Please describe any alternatives you've considered, even if you've dismissed them.

tohuynh avatar Mar 09 '22 03:03 tohuynh

I can look into it, but I need to understand something:Vote has a reference to Event, and Event has a datetime. Does this satisfy the requirement for having datetime accessible from Vote?

Shak2000 avatar May 23 '22 02:05 Shak2000

Vote has a reference to Event, and Event has a datetime. Does this satisfy the requirement for having datetime accessible from Vote?

It would, but the query to sort/filter a person's votes by the event's datetime would be inefficient, as the query would need to populate/fill in the Event for each Vote. Sorting/filtering votes by the event's datetime would force us to fetch all votes and populate the Event reference field for each vote(populating is just making a request to the database to fill in the reference field) and currently the database only allows a limited number of concurrent requests ( we have to make concurrent requests or the page will have high latency).

See the source of this issue.

tohuynh avatar May 23 '22 03:05 tohuynh

Agree with To's writeup. The Vote having a reference to Event is not enough. For faster querying and direct filtering we need the vote_datetime on the Vote model.

evamaxfield avatar May 23 '22 23:05 evamaxfield