Skip to content

Commit

Permalink
working json filter, return only filter info
Browse files Browse the repository at this point in the history
  • Loading branch information
alx committed Jul 19, 2011
1 parent f770375 commit b8bc452
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 19 deletions.
3 changes: 2 additions & 1 deletion json_server/application.rb
Expand Up @@ -24,9 +24,10 @@


get '/heatmap' do get '/heatmap' do
content_type :json content_type :json
$SEATS.each{|seat| seat[:count] = 0}
month = 201104 month = 201104
3.times do 3.times do
parse_synthese "#{month}" parse_synthese "#{month}", params[:info]
month += 1 month += 1
end end
max = 0 max = 0
Expand Down
16 changes: 14 additions & 2 deletions json_server/lib/json_parser.rb
Expand Up @@ -56,11 +56,23 @@ def api_json(json_url)
end end
end end


def parse_synthese(date) def parse_synthese(date, info)
json = api_json("http://www.nosdeputes.fr/synthese/#{date}/json") json = api_json("http://www.nosdeputes.fr/synthese/#{date}/json")
json["deputes"].each do |depute_json| json["deputes"].each do |depute_json|
depute = depute_json["depute"] depute = depute_json["depute"]
nb_interventions = depute["hemicycle_interventions"]
nb_interventions = case info
when "amendements"
depute["amendements_adoptes"] + depute["amendements_signes"]
when "commissions"
depute["commission_interventions"] + depute["commission_presences"]
when "hemicycle"
depute["hemicycle_interventions"] + depute["hemicycle_interventions_courtes"]
when "propositions"
depute["propositions_ecrites"] + depute["propositions_signees"]
when "questions"
depute["questions_ecrites"] + depute["questions_orales"]
end
seat_index = $NAMES.index{|store| store[:name] == depute["nom"]} seat_index = $NAMES.index{|store| store[:name] == depute["nom"]}
if seat_index.to_i > 0 && nb_interventions > 0 if seat_index.to_i > 0 && nb_interventions > 0
if seat = $SEATS.select{|seat| seat[:id] == seat_index}.first if seat = $SEATS.select{|seat| seat[:id] == seat_index}.first
Expand Down
8 changes: 6 additions & 2 deletions json_server/public/css/style.css
@@ -1,3 +1,7 @@
.container {
margin-top:10px;
}

#heatmapArea { #heatmapArea {
position: relative; position: relative;
float: left; float: left;
Expand All @@ -12,15 +16,15 @@
color: white; color: white;
padding: 3px 5px 5px 10px; padding: 3px 5px 5px 10px;
position: relative; position: relative;
top: 3px; top: 1px;
} }


#heatmap_tooltip{ #heatmap_tooltip{
background: #009; background: #009;
color: white; color: white;
padding: 3px 5px 5px 10px; padding: 3px 5px 5px 10px;
position: relative; position: relative;
top: 3px; top: 1px;
} }


#filter{ #filter{
Expand Down

0 comments on commit b8bc452

Please sign in to comment.