Skip to content
This repository
Browse code

added contact congress stats page

  • Loading branch information...
commit 838ca085ece2e6e42a38a58f4d9ff8d32468e9d3 1 parent 08bb538
aross authored March 16, 2012
5  app/controllers/admin/contact_congress_controller.rb
@@ -10,4 +10,9 @@ def letters
10 10
     @page_title = 'Contact Congress Letters'
11 11
     @letters = ContactCongressLetter.order('created_at DESC').all.paginate(:per_page => 50, :page => params[:page])
12 12
   end
  13
+  
  14
+  def stats
  15
+    @page_title = 'Contact Congress Stats'
  16
+    @people = Person.all_sitting
  17
+  end
13 18
 end
2  app/models/person.rb
@@ -1561,7 +1561,7 @@ def formageddon_display_address
1561 1561
     addr += "#{congress_office}\n" unless congress_office.blank?
1562 1562
     addr += "Washington, DC #{office_zip}\n"
1563 1563
   end
1564  
-
  1564
+  
1565 1565
   SERIALIZATION_OPS = {:methods => [:oc_user_comments, :oc_users_tracking], :include => [:recent_news, :recent_blogs]}.freeze
1566 1566
 
1567 1567
   def as_json(ops = {})
26  app/views/admin/contact_congress/stats.html.haml
... ...
@@ -0,0 +1,26 @@
  1
+.padding
  2
+  %table.contact_steps_list
  3
+    %tr
  4
+      %th Recipient
  5
+      %th # of Letters
  6
+      %th Successful deliveries
  7
+      %th Warnings
  8
+      %th Errors
  9
+      %th Replies
  10
+    %tr
  11
+      %th Congress
  12
+      %th= Formageddon::FormageddonThread.count
  13
+      %th= Formageddon::FormageddonLetter.where("formageddon_letters.status = 'SENT'").size
  14
+      %th= Formageddon::FormageddonLetter.where("formageddon_letters.status like 'WARNING%'").size
  15
+      %th= Formageddon::FormageddonLetter.where("formageddon_letters.status like 'ERROR%'").size
  16
+      %th= Formageddon::FormageddonLetter.where("formageddon_letters.status = 'RECEIVED'").size
  17
+        
  18
+    - @people.each do |p|
  19
+      %tr
  20
+        %td= p.name
  21
+        %td= p.formageddon_threads.size
  22
+        %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status = 'SENT'").size
  23
+        %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status like 'WARNING%'").size
  24
+        %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status like 'ERROR%'").size
  25
+        %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status = 'RECEIVED'").size
  26
+        
1  app/views/admin/index/index.html.erb
@@ -55,6 +55,7 @@
55 55
     <br />
56 56
     <h3>Contact Congress</h3>
57 57
     <li><%= link_to 'Manage Recipient Configuration', '/admin/contact_congress' %>
  58
+    <li><%= link_to 'Letter Stats', '/admin/contact_congress/stats' %>
58 59
     <li><%= link_to 'View Sent Letters', '/admin/contact_congress/letters' %>
59 60
   <% end %>
60 61
   </ul>
2  db/migrate/20120316192137_formageddon_indexes.rb
@@ -7,6 +7,7 @@ def self.up
7 7
     add_index :formageddon_form_fields, :formageddon_form_id
8 8
     add_index :formageddon_form_captcha_images, :formageddon_form_id
9 9
     add_index :formageddon_delivery_attempts, :formageddon_letter_id
  10
+    add_index :formageddon_letters, :status
10 11
   end
11 12
 
12 13
   def self.down
@@ -17,5 +18,6 @@ def self.down
17 18
     remove_index :formageddon_form_fields, :formageddon_form_id
18 19
     remove_index :formageddon_form_captcha_images, :formageddon_form_id
19 20
     remove_index :formageddon_delivery_attempts, :formageddon_letter_id
  21
+    remove_index :formageddon_letters, :status
20 22
   end
21 23
 end

0 notes on commit 838ca08

Please sign in to comment.
Something went wrong with that request. Please try again.