--- trunk/bin/irc-logger.pl 2007/06/08 12:12:45 64 +++ trunk/bin/irc-logger.pl 2007/09/29 13:13:41 67 @@ -260,16 +260,21 @@ my $sql = $context ? $sql_context : $sql_message; - $sql .= " where message ilike ? or nick ilike ? " if ($args->{search}); - $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} }); - if ($args->{date}) { - my $date = eval { DateTime::Format::ISO8601->parse_datetime( $args->{date} )->ymd; }; + sub check_date { + my $date = shift; + $date = eval { DateTime::Format::ISO8601->parse_datetime( $args->{date} )->ymd; }; if ( $@ ) { warn "invalid date ", $args->{date}, $/; $date = DateTime->now->ymd; } + return $date; + } + + $sql .= " where message ilike ? or nick ilike ? " if ($args->{search}); + $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} }); + if ($args->{date}) { $sql .= " where date(time) = ? "; - $args->{date} = $date; + $args->{date} = check_date( $args->{date} ); } $sql .= " order by log.time desc"; $sql .= " limit " . $args->{limit} if ($args->{limit}); @@ -284,7 +289,7 @@ $sth->execute(); _log "tag '$tag' returned ", $sth->rows, " results ", $context || ''; } elsif (my $date = $args->{date}) { - $sth->execute($date); + $sth->execute( check_date($date) ); _log "found ", $sth->rows, " messages for date $date ", $context || ''; } else { $sth->execute(); @@ -855,6 +860,8 @@ .col-3 { background: #ff9999 } .col-4 { background: #ff66ff } */ +.calendar { border: 1px solid red; width: 100%; } +.month { border: 0px; width: 100%; } _END_OF_STYLE_ my $max_color = 4; @@ -907,28 +914,42 @@ qq{
}; if ($request->url =~ m#/history#) { my $sth = $dbh->prepare(qq{ - select date(time) as date,count(*) as nr + select date(time) as date,count(*) as nr,sum(length(message)) as len from log group by date(time) order by date(time) desc }); $sth->execute(); my ($l_yyyy,$l_mm) = (0,0); + $html .= qq{
} . $cal->as_HTML() . qq{ | }; + $ord++; + $html .= qq{
} . $cal->as_HTML() . qq{ |
", @@ -936,7 +957,7 @@ limit => $q->param('last') || $q->param('date') ? undef : 100, search => $search || undef, tag => $q->param('tag') || undef, - date => $q->param('date') || undef, + date => check_date( $q->param('date') ), fmt => { date => sub { my $date = shift || return;