Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added contact congress stats page

  • Loading branch information...
commit 838ca085ece2e6e42a38a58f4d9ff8d32468e9d3 1 parent 08bb538
@aross aross authored
View
5 app/controllers/admin/contact_congress_controller.rb
@@ -10,4 +10,9 @@ def letters
@page_title = 'Contact Congress Letters'
@letters = ContactCongressLetter.order('created_at DESC').all.paginate(:per_page => 50, :page => params[:page])
end
+
+ def stats
+ @page_title = 'Contact Congress Stats'
+ @people = Person.all_sitting
+ end
end
View
2  app/models/person.rb
@@ -1561,7 +1561,7 @@ def formageddon_display_address
addr += "#{congress_office}\n" unless congress_office.blank?
addr += "Washington, DC #{office_zip}\n"
end
-
+
SERIALIZATION_OPS = {:methods => [:oc_user_comments, :oc_users_tracking], :include => [:recent_news, :recent_blogs]}.freeze
def as_json(ops = {})
View
26 app/views/admin/contact_congress/stats.html.haml
@@ -0,0 +1,26 @@
+.padding
+ %table.contact_steps_list
+ %tr
+ %th Recipient
+ %th # of Letters
+ %th Successful deliveries
+ %th Warnings
+ %th Errors
+ %th Replies
+ %tr
+ %th Congress
+ %th= Formageddon::FormageddonThread.count
+ %th= Formageddon::FormageddonLetter.where("formageddon_letters.status = 'SENT'").size
+ %th= Formageddon::FormageddonLetter.where("formageddon_letters.status like 'WARNING%'").size
+ %th= Formageddon::FormageddonLetter.where("formageddon_letters.status like 'ERROR%'").size
+ %th= Formageddon::FormageddonLetter.where("formageddon_letters.status = 'RECEIVED'").size
+
+ - @people.each do |p|
+ %tr
+ %td= p.name
+ %td= p.formageddon_threads.size
+ %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status = 'SENT'").size
+ %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status like 'WARNING%'").size
+ %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status like 'ERROR%'").size
+ %td= p.formageddon_threads.includes(:formageddon_letters).where("formageddon_letters.status = 'RECEIVED'").size
+
View
1  app/views/admin/index/index.html.erb
@@ -55,6 +55,7 @@
<br />
<h3>Contact Congress</h3>
<li><%= link_to 'Manage Recipient Configuration', '/admin/contact_congress' %>
+ <li><%= link_to 'Letter Stats', '/admin/contact_congress/stats' %>
<li><%= link_to 'View Sent Letters', '/admin/contact_congress/letters' %>
<% end %>
</ul>
View
2  db/migrate/20120316192137_formageddon_indexes.rb
@@ -7,6 +7,7 @@ def self.up
add_index :formageddon_form_fields, :formageddon_form_id
add_index :formageddon_form_captcha_images, :formageddon_form_id
add_index :formageddon_delivery_attempts, :formageddon_letter_id
+ add_index :formageddon_letters, :status
end
def self.down
@@ -17,5 +18,6 @@ def self.down
remove_index :formageddon_form_fields, :formageddon_form_id
remove_index :formageddon_form_captcha_images, :formageddon_form_id
remove_index :formageddon_delivery_attempts, :formageddon_letter_id
+ remove_index :formageddon_letters, :status
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.