-
-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fix server error on user profile vote summary tab if there are orphaned votes #1491
base: develop
Are you sure you want to change the base?
Conversation
LGTM based on inspection (one paranoid request). I appreciate the extra resilience in the view and controller. Someone with more knowledge of the scripts/daily jobs should also review this. How do we test it? Can we inject some bad data on the dev server and test there before going to production? |
There are several ways of doing so. A simple prerequisite is voting on something, then intentionally breaking the database integrity by updating the record in the After that's done, it's just a matter of executing the job. The simplest approach is to change the associated script file to call |
.select('count(*) as vote_count') \ | ||
.select('date(created_at) as date_of') | ||
@votes = Vote.where(recv_user: @user) | ||
.joins(:post) |
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.
As far as I can see these two diffs are identical (excepting blank space) except this line - changed from an includes
to a joins
. Unless Rails has changed something since I last knew about it, joins
doesn't preload the referenced table, which is what includes
does. What's the reasoning behind this change?
0d7f037
to
b317c40
Compare
Closes #1488
This PR fixes the issue with orphan votes (with
post_id
but no actual post) by:CleanupVotes
daily job that removes orphaned votes (those that do not correspond to any post but still have apost_id
assigned to them);post
not being present;