Commit 3e8e995f9ef542f97f96738864fa25819ead3630

Authored by Hugo Melo
1 parent 0fc833ce

Fix vote filtering by profile on export_ranking

Showing 1 changed file with 4 additions and 1 deletions   Show diff stats
script/export_ranking.rb
... ... @@ -37,15 +37,18 @@ profile_ids.each do |profile_id|
37 37 person_down_votes = person.comments.joins(:votes).where('vote < 0').count + person_articles.joins(:votes).where('vote < 0').count
38 38 person_comments = person.comments.count
39 39 person_followers = (person.following_articles & person.article_followers.where(article_id: person_articles)).count
  40 + votes = Vote.for_voter(person).count
40 41 else
41 42 person_articles = profile.articles.where(:author_id => person.id)
42 43 person_up_votes = person.comments.where(:source_id => profile.articles).joins(:votes).where('vote > 0').count + person_articles.joins(:votes).where('vote > 0').count
43 44 person_down_votes = person.comments.where(:source_id => profile.articles).joins(:votes).where('vote < 0').count + person_articles.joins(:votes).where('vote < 0').count
44 45 person_comments = person.comments.where(:source_id => profile.articles).count
45 46 person_followers = (person.following_articles & person.article_followers.where(article_id: profile.articles)).count
  47 + the_votes = Vote.for_voter(person)
  48 + votes = the_votes.where(voteable_type: 'Article', voteable_id: profile.articles).count + the_votes.where(voteable_type: 'Comment', voteable_id: Comment.where(source_type: ["ProposalsDiscussionPlugin::Proposal", "Article"], source_id: profile.articles)).count
46 49 end
47 50 quantities_values = [
48   - Vote.for_voter(person).count,
  51 + votes,
49 52 person.friends.count,
50 53 person_up_votes,
51 54 person_down_votes,
... ...