Skip to content

Commit

Permalink
Changed cache location for states. Fixed state loading of cache
Browse files Browse the repository at this point in the history
  • Loading branch information
ajturner committed Nov 4, 2008
1 parent 94ed1d3 commit 65712c1
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
6 changes: 3 additions & 3 deletions app/models/report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ def display_html
else
html << %Q{<br /><img src="#{self.reporter.icon}" class="profile" />}
end
if(item.rating.nil?)
if(self.rating.nil?)
rating_icon = "/images/rating_none.png"
elsif(item.rating <= 30)
elsif(self.rating <= 30)
rating_icon = "/images/rating_bad.png"
elsif (item.rating <= 70)
elsif (self.rating <= 70)
rating_icon = "/images/rating_medium.png"
else
rating_icon = "/images/rating_good.png"
Expand Down
2 changes: 1 addition & 1 deletion app/views/reports/_legend.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
<div class="filters">
<h2>Available filters:</h2>
<ul class="nobullets">
<li>View state-by-state: <%= state_select %></li>
<li><a href="#" onclick="return updateMap('count=100')">Show last 100 reports</a></li>
<li><a href="#" onclick="return updateMap('wait_time=90')">Show wait time > 90 minutes</a></li>
<li><a href="#" onclick="return updateMap('rating=30')">Show only bad ratings</a></li>
<li>View state-by-state: <%= state_select %></li>
</ul>
</div>

Expand Down
4 changes: 2 additions & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
map.connect 'local/:filter', :controller => "reports", :action => "index"

map.kml_feed 'feeds/:count.kml', :controller => "reports", :action => "index", :format => :kml
map.json_feed 'feeds/:page.json', :controller => "reports", :action => "index"
map.json_state_feed 'feeds/:state/:page.json', :controller => "reports", :action => "index"
map.json_feed 'feeds/:page.json', :controller => "reports", :action => "index", :format => :jso
map.json_state_feed 'feeds/state/:state/:page.json', :controller => "reports", :action => "index"

map.resources :reports,
:collection => {
Expand Down
19 changes: 17 additions & 2 deletions public/javascripts/mapping.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ function initMapJS(map_filters){

$("#filter_state").change(function () {
state = $("#filter_state").val();
updateMap("state/"+state);
updateState(state);
});
// display the map centered on a latitude and longitude (Google zoom levels)
var myPoint = new LatLonPoint(38, -90);
Expand All @@ -74,6 +74,21 @@ function initMapJS(map_filters){

}

function updateState(state, page) {
var current_filter = "";
if(page == null)
page = 1;
hideMessage();

mapstraction.removeAllMarkers();
fadeMap();
gmarkers = [];
filters = current_filter = "state=" + state;

$("#update_status").show();
$.getJSON("/feeds/state/"+state+"/" + page +".json", "");
return false;
}
function updateMap(map_filter) {
var current_filter = "";
hideMessage();
Expand All @@ -88,7 +103,7 @@ function updateMap(map_filter) {
}

$("#update_status").show();
$.getJSON("/feeds/json/"+current_filter+"/1/200/0.json", "");
$.getJSON("/reports.json?"+current_filter+"&page=1&count=200&callback=updateJSON", "");
return false;
}
function showMessage(message) {
Expand Down
12 changes: 10 additions & 2 deletions script/cachefiles
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ while (1)
open(ATOM, ">reports.atom");
print ATOM $content;
close(ATOM);
move("reports.atom", "public/feeds/reports.atom");
move("reports.atom", "/home/votereport/current/public/reports.atom");

$res = $ua->get("http://votereport.us/reports.kml");
$content = $res->content;
open(ATOM, ">reports.kml");
print ATOM $content;
close(ATOM);
move("reports.atom", "/home/votereport/current/public/reports.kml");

#print "KML and Atom fetched.\n";
for (my $i=0;$i<scalar @abbr;$i++)
{
Expand All @@ -50,7 +58,7 @@ sub state
my $res = $ua->get("http://votereport.us/reports.json?state=$state&wait_time=0&per_page=200&callback=updateJSON&page=$i");
print STATE $res->content;
close STATE;
my $fdir = "/home/votereport/current/public/feeds/json";
my $fdir = "/home/votereport/current/public/feeds/state";
mkdir($fdir) unless (-d $fdir);
mkdir("$fdir/$state") unless (-d "$fdir/$state");
move("$i.json", "$fdir/$state/$i.json");
Expand Down

0 comments on commit 65712c1

Please sign in to comment.