summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2016-04-09 18:10:13 +0200
committerDaniel Friesel <derf@finalrewind.org>2016-04-09 18:10:13 +0200
commitd14e3af4b280f3236f8ed8080fad667a519ca176 (patch)
tree6545344c531f8bad440fcef80182d50715060276
parente765e6985fac2986c266d67d575d0d5cc4b6f914 (diff)
allow filtering by monthHEADmaster
-rw-r--r--index.pl13
1 files changed, 13 insertions, 0 deletions
diff --git a/index.pl b/index.pl
index 06fcf9c..2ca52e8 100644
--- a/index.pl
+++ b/index.pl
@@ -47,6 +47,9 @@ helper barplot_args => sub {
line => {
desc => 'Linie',
},
+ month => {
+ desc => 'Monat',
+ },
station => {
desc => 'Bahnhof',
},
@@ -368,6 +371,8 @@ helper 'get_2ddata' => sub {
my ( $filter, $filter_clause ) = $self->parse_filter_args;
my @weekdays = qw(So Mo Di Mi Do Fr Sa);
+ my @months = qw(BUG Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez);
+ $months[3] = encode( 'utf-8', $months[3] );
if ( $msgnum < 0 or $msgnum > 99 ) {
$msgnum = 0;
@@ -389,6 +394,9 @@ helper 'get_2ddata' => sub {
$format
= 'extract(dow from scheduled_time at time zone \'GMT\') || \' \' || to_char(scheduled_time at time zone \'GMT\', \'HH24\')';
}
+ when ('month') {
+ $format = 'extract(month from scheduled_time at time zone \'GMT\')';
+ }
when ('line') {
$format = 'train_types.name || \' \' || lines.name';
$where_clause = 'line_no is not null';
@@ -505,6 +513,11 @@ helper 'get_2ddata' => sub {
# SQL starts on sunday, we'd like to start on monday
@{$dbres} = ( @{$dbres}[ 1 .. 6 ], $dbres->[0] );
}
+ elsif ( $aggregate eq 'month' ) {
+ for my $row ( @{$dbres} ) {
+ splice( @{$row}, 0, 1, $months[ $row->[0] ] );
+ }
+ }
elsif ( $aggregate eq 'weekhour' ) {
# the result only contains columns for datetimes with departures, so