Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: skimbrel/how-fucked-is-muni
base: 9077718f63
...
head fork: skimbrel/how-fucked-is-muni
compare: 4cd9af8f38
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
2  environments/development.yml
View
@@ -34,4 +34,4 @@ agency: "sf-muni"
redis_server: "127.0.0.1:6379"
# How often we should refresh our data (in seconds)
-refresh_period: 60
+refresh_period: 300
2  environments/production.yml
View
@@ -24,5 +24,5 @@ agency: "sf-muni"
redis_server: "127.0.0.1:6379"
# How often we should refresh our data (in seconds)
-refresh_period: 300
+refresh_period: 600 # ten minutes should be fine
2  lib/HowFuckedIsMuni.pm
View
@@ -9,7 +9,7 @@ get '/' => sub {
try {
my $checker = HowFuckedIsMuni::RouteChecker->instance();
my $colors = HowFuckedIsMuni::RouteColors->new();
- my $routes = $checker->get_routes(config->{agency});
+ my $routes = $checker->check_all_routes(config->{agency});
my $names = $checker->get_sorted_names(config->{agency});
template 'index', { agency => config->{agency}, names => $names, routes => $routes, colors => $colors };
}
25 lib/HowFuckedIsMuni/RouteChecker.pm
View
@@ -16,6 +16,11 @@ use constant GAP_FACTOR => 0.1;
use constant SHORT_EXPTIME => '5 minutes';
use constant LONG_EXPTIME => '1 day';
+sub check_all_key {
+ my $agency = shift;
+ return "status-all:$agency";
+}
+
sub routes_key {
my $agency = shift;
return "routes:$agency";
@@ -74,6 +79,26 @@ sub instance {
return $singleton;
}
+sub check_all_routes {
+ my $self = shift;
+ my ($agency) = @_;
+
+ my $key = check_all_key($agency);
+ return $self->cache->compute($key, SHORT_EXPTIME, sub {
+ my $routes = $self->get_routes($agency);
+ my @ids = keys %{$routes};
+ my $all = {};
+ for my $id (@ids) {
+ my $status = $self->check_route($agency, $id);
+ $all->{$id} = {
+ name => $routes->{$id},
+ status => $status,
+ };
+ }
+ return $all;
+ });
+}
+
sub check_route {
my $self = shift;
my ($agency, $route) = @_;
19 public/css/style.css
View
@@ -35,7 +35,7 @@ div.container {
margin-right: 10%;
}
-div.circle {
+div.okay {
width: 3em; height: 3em;
-webkit-border-radius: 1.5em; -moz-border-radius: 1.5em;
font-family: "Helvetica", "Arial", sans-serif;
@@ -51,6 +51,23 @@ div.circle {
cursor: pointer;
}
+div.fucked {
+ width: 3em; height: 3em;
+ -webkit-border-radius: 1.5em; -moz-border-radius: 1.5em;
+ font-family: "Helvetica", "Arial", sans-serif;
+ font-weight: bold;
+ font-size: 36px;
+ text-align: center;
+ text-decoration: line-through;
+ float: left;
+ margin-left: 0.5em;
+ margin-right: 0.5em;
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+ line-height: 3em;
+ cursor: pointer;
+}
+
#statsarea {
margin-left: 35%;
width: 70%;
12 views/index.tt
View
@@ -11,9 +11,13 @@
owl = 0
%]
[% END %]
-<div class="circle" style="background-color: [% colors.background(agency, key) %];">
-<a class="route" href="/[% key %]" title="[% routes.$key %]" style="color: [% colors.foreground(agency, key) %];">[% name %]</a>
-[% IF owl %]<span style="font-size: 14px; color: [% colors.foreground(agency, key) %]">OWL</span>[% END %]
+[% IF routes.$key.status.is_fucked %]
+<div class="fucked" style="background-color: [% colors.background(agency, key) %];">
+[% ELSE %]
+<div class="okay" style="background-color: [% colors.background(agency, key) %];">
+[% END %]
+<a class="route" href="/[% key %]" title="[% routes.$key.name %]" style="color: [% colors.foreground(agency, key) %];">[% name %]</a>
+[% IF owl %]<span style="font-size: 14px; color: [% colors.foreground(agency, key) %]">OWL</span>[% END %]
</div>
[% END %]
</div>
@@ -22,4 +26,4 @@ $(".circle").click(function(){
window.location=$(this).find("a").attr("href");
return false;
});
-</script>
+</script>

No commit comments for this range

Something went wrong with that request. Please try again.