Reputation: 1360
I have a page where I'm displaying the title of something. Users are allowed to provide their own suggested titles. The title I originally display is stored under the event's object. All suggestions are stored in their own table. Each suggestion has a vote count associated with it. I want to display the original title unless there is a suggestion that is above some threshold of votes, but if several are above that threshold, I want to display the highest one. How would I grab the highest-voted suggestion from the list, but only if it is above some arbitrary threshold, let's say 5?
Upvotes: 0
Views: 63
Reputation: 3712
Add an integer field for the number of suggestions for a suggestion model.
Then find the highest suggestion and check if it has more than 5 votes
Upvotes: 1