Skip to content

Commit

Permalink
Make an API to see co-op stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Luke Closs committed Aug 23, 2011
1 parent 2f5f313 commit fc6f3de
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/Biopay.pm
Expand Up @@ -24,7 +24,7 @@ my %public_paths = (
map { $_ => 1 }
qw( / /login /logout /terms /refunds /privacy),
'/forgot-password', '/admin-login', '/biodiesel-faq',
'/new-member',
'/new-member', '/stats.json',
);

before sub {
Expand Down Expand Up @@ -122,6 +122,10 @@ EOT
}
};

get '/stats.json' => sub {
return Biopay::Stats->new->as_hash;
};

get '/login' => sub {
template 'login' => {
message => param('message') || '',
Expand Down
3 changes: 3 additions & 0 deletions lib/Biopay/Stats.pm
Expand Up @@ -19,3 +19,6 @@ sub view {
return int $result->{rows}[0]{value};
}

method as_hash {
return { map { $_ => $self->$_ } qw/fuel_sold_alltime active_members/ };
}

0 comments on commit fc6f3de

Please sign in to comment.