-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Count user's votes by subquery #3477
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Signed-off-by: dartcafe <github@dartcafe.de>
Signed-off-by: dartcafe <github@dartcafe.de>
OK. The IParam has to be defined outside of the subquery method. |
Signed-off-by: dartcafe <github@dartcafe.de>
Signed-off-by: dartcafe <github@dartcafe.de>
@come-nc Do you think it is a little bit overengeneered? |
Signed-off-by: dartcafe <github@dartcafe.de>
Hello, We looked into it and I think it would be best to avoid subqueries and limit ourselves to counts, sums and joins. Couldn’t the orphaned votes simply be cleared at option deletion, or by a background job? |
This is the problem. Deleted options are kept by intention, in case an option is deleted accitentially or is to be added again after deletion. User's votes should be kept in these cases. This is why I think a subquery is better than running recursively over the result list. The other problem is that vote counts get multiplied by the avialable options before changing to the subquery. Sure, this could be solved in a join as well, but for me it works. Please take also a look into #3479. I tried to solve the frontend rendering problems by chunking the polls list and by reducing the polls in the navigation to a maximum of 6 entries. Chunking the polls list works by only rendering 20 items and add 20 more by reaching the list bottom by scrolling. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works and is better than previous state.
Having two separate subqueries for vote count and yes vote count seems suboptimal but let’s merge that for now it’s better anyway.
Maybe squash commits to help with backporting?
:-) I went the lazy way, and avoided figuring out how to selct two results from the subquery. Any hint for improvement is welcome. |
Ah damn, I forgot to squash. @come-nc |
The current approach to count a user's votes by a join statement returns a by the count of options multiplied result
This replaces selects on the votes table for every poll
to dos