1module AdminHubHelper |
|
|
2 def petition_total_count |
3 @petition_total_count ||= Petition.all.count |
|
4 end |
|
|
6 def archived_petition_total_count |
7 @archived_petition_total_count ||= Archived::Petition.all.count |
|
8 end |
|
|
10 def in_moderation_count |
11 @in_moderation_count ||= Petition.in_moderation.count |
|
12 end |
|
|
14 def recently_in_moderation_count |
15 @recently_in_moderation_count ||= Petition.recently_in_moderation.count |
|
16 end |
|
|
18 def recently_in_moderation_untagged_count |
19 @recently_in_moderation_untagged_count ||= Petition.untagged.recently_in_moderation.count |
|
20 end |
|
|
22 def nearly_overdue_in_moderation_untagged_count |
23 @nearly_overdue_in_moderation_untagged_count ||= Petition.untagged.nearly_overdue_in_moderation.count |
|
24 end |
|
|
26 def nearly_overdue_in_moderation_count |
27 @nearly_overdue_in_moderation_count ||= Petition.nearly_overdue_in_moderation.count |
|
28 end |
|
|
30 def overdue_in_moderation_count |
31 @overdue_in_moderation_count ||= Petition.overdue_in_moderation.count |
|
32 end |
|
|
34 def overdue_in_moderation_untagged_count |
35 @overdue_in_moderation_untagged_count ||= Petition.untagged.overdue_in_moderation.count |
|
36 end |
|
|
38 def tagged_in_moderation_count |
39 @tagged_in_moderation_count ||= Petition.tagged_in_moderation.count |
|
40 end |
|
|
42 def untagged_in_moderation_count |
43 @untagged_in_moderation_count ||= Petition.untagged_in_moderation.count |
|
44 end |
|
|
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
|
|
|
61 def counts |
62 @counts ||= generate_counts |
|
63 end |
|
|
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 |
|
|
72 def action_counts(&block) |
73 counts = ActionCountsDecorator.new |
|
74 yield counts |
|
75 end |
|
|
77 def action_count(key, count) |
78 t(:"#{key}.html", scope: :"petitions.action_counts", formatted_count: number_with_delimiter(count)) |
|
79 end |
|
80end |