1module AdminHubHelper
  • Complexity 1 » saikuro
2  def petition_total_count
 
3    @petition_total_count ||= Petition.all.count
 
4  end
 
5
  • Complexity 1 » saikuro
6  def archived_petition_total_count
 
7    @archived_petition_total_count ||= Archived::Petition.all.count
 
8  end
 
 9
  • Complexity 1 » saikuro
10  def in_moderation_count
 
11    @in_moderation_count ||= Petition.in_moderation.count
 
12  end
 
  • Complexity 1 » saikuro
14  def recently_in_moderation_count
 
15    @recently_in_moderation_count ||= Petition.recently_in_moderation.count
 
16  end
 
  • Complexity 1 » saikuro
18  def recently_in_moderation_untagged_count
 
19    @recently_in_moderation_untagged_count ||= Petition.untagged.recently_in_moderation.count
 
20  end
 
  • Complexity 1 » saikuro
22  def nearly_overdue_in_moderation_untagged_count
 
23    @nearly_overdue_in_moderation_untagged_count ||= Petition.untagged.nearly_overdue_in_moderation.count
 
24  end
 
  • Complexity 1 » saikuro
26  def nearly_overdue_in_moderation_count
 
27    @nearly_overdue_in_moderation_count ||= Petition.nearly_overdue_in_moderation.count
 
28  end
 
  • Complexity 1 » saikuro
30  def overdue_in_moderation_count
 
31    @overdue_in_moderation_count ||= Petition.overdue_in_moderation.count
 
32  end
 
  • Complexity 1 » saikuro
34  def overdue_in_moderation_untagged_count
 
35    @overdue_in_moderation_untagged_count ||= Petition.untagged.overdue_in_moderation.count
 
36  end
 
  • Complexity 1 » saikuro
38  def tagged_in_moderation_count
 
39    @tagged_in_moderation_count ||= Petition.tagged_in_moderation.count
 
40  end
 
  • Complexity 1 » saikuro
42  def untagged_in_moderation_count
 
43    @untagged_in_moderation_count ||= Petition.untagged_in_moderation.count
 
44  end
 
  • Complexity 3 » saikuro
46  def summary_class_name_for_in_moderation
 
47    if overdue_in_moderation_count > 0
 
48      "queue-danger"
 
49    elsif nearly_overdue_in_moderation_count > 0
 
50      "queue-caution"
 
51    else
 
52      "queue-stable"
 
53    end
 
54  end
 
 
56  class ActionCountsDecorator
 
57    delegate :each, :empty?, to: :counts
 
 
59    private
 
  • Complexity 1 » saikuro
61    def counts
 
62      @counts ||= generate_counts
 
63    end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
65    def generate_counts
 
66      counts = []
 
67      counts << [:awaiting_response, Petition.visible.awaiting_response.count]
 
68      counts << [:in_debate_queue, Petition.in_debate_queue.count]
 
69    end
 
70  end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
72  def action_counts(&block)
 
73    counts = ActionCountsDecorator.new
 
74    yield counts
 
75  end
 
  • Complexity 1 » saikuro
77  def action_count(key, count)
 
78    t(:"#{key}.html", scope: :"petitions.action_counts", formatted_count: number_with_delimiter(count))
 
79  end
 
80end