Extract method to get vote counts by votable type

This commit is contained in:
Javi Martín
2023-07-01 22:08:05 +02:00
parent 0d35bddf9e
commit 9491b20314
4 changed files with 21 additions and 7 deletions

View File

@@ -7,9 +7,9 @@ class Admin::StatsController < Admin::BaseController
@proposals = Proposal.with_hidden.count
@comments = Comment.not_valuations.with_hidden.count
@debate_votes = Vote.where(votable_type: "Debate").count
@proposal_votes = Vote.where(votable_type: "Proposal").count
@comment_votes = Vote.where(votable_type: "Comment").count
@debate_votes = Vote.count_for("Debate")
@proposal_votes = Vote.count_for("Proposal")
@comment_votes = Vote.count_for("Comment")
@votes = Vote.count