Created
September 3, 2013 21:22
-
-
Save boriscy/6429799 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Controllers | |
============== | |
class HomeController < ApplicationController | |
def votes | |
@lista_pueblo = Table.sum(:lista_pueblo) | |
@lista_sur = Table.sum(:lista_sur) | |
@lista_frente_grande = Table.sum(:lista_frente_grande) | |
@lista_union_pro = Table.sum(:lista_union_pro) | |
@lista_radical = Table.sum(:lista_radical) | |
@lista_frente_para_la_victoria = Table.sum(:lista_frente_para_la_victoria) | |
@total_votes_positive = @lista_pueblo + @lista_sur + @lista_frente_grande + @lista_union_pro + @lista_radical + @lista_frente_para_la_victoria | |
@total_votes = @lista_pueblo + @lista_sur + @lista_frente_grande + @lista_union_pro + @lista_radical + @lista_frente_para_la_victoria + Table.sum(:votes_blank) + Table.sum(:votes_nil) | |
@votantes = @total_votes.to_f*100/83535 | |
@totalmesas=242 | |
@totalvotantes=83535 | |
@mesas_escrutadas = School.joins(:tables).where('tables.lista_frente_para_la_victoria != 0', true) | |
@avg = @mesas_escrutadas.count.to_f * @mesas_escrutadas.all(:select => 'distinct tables.*').count / 100 | |
@avg_mesas= @mesas_escrutadas.count.to_f * 100 /@totalmesas | |
end | |
def schools | |
@data = [] | |
School.includes(:tables).order(:name).all.each do |school| | |
lista_pueblo = school.tables.sum(:lista_pueblo) | |
lista_sur = school.tables.sum(:lista_sur) | |
lista_frente_grande = school.tables.sum(:lista_frente_grande) | |
lista_union_pro = school.tables.sum(:lista_union_pro) | |
lista_radical = school.tables.sum(:lista_radical) | |
lista_frente_para_la_victoria = school.tables.sum(:lista_frente_para_la_victoria) | |
votes = lista_pueblo + lista_sur + lista_frente_grande + lista_union_pro + lista_radical + lista_frente_para_la_victoria | |
mesas = School.includes(:tables).count | |
@mesas_school = Table.select("count(*), school_id").group(:school_id) | |
@school_names = Hash[School.all.map {|v| [v.id, v.name] } ] | |
@data << {id: school.id, name: school.name, processed: votes != 0, lista_pueblo: lista_pueblo , lista_sur: lista_sur , lista_frente_grande: lista_frente_grande , lista_union_pro: lista_union_pro , lista_radical: lista_radical , lista_frente_para_la_victoria: lista_frente_para_la_victoria} | |
end | |
end | |
def grid | |
@schools = School.includes(:tables).order(:name) | |
end | |
def circuit | |
@circuits = School.includes(:tables).order(:name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment