/[irc-logger]/trunk/bin/irc-logger.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/irc-logger.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 66 by dpavlin, Fri Jun 8 12:17:35 2007 UTC revision 67 by dpavlin, Sat Sep 29 13:13:41 2007 UTC
# Line 260  sub get_from_log { Line 260  sub get_from_log {
260    
261          my $sql = $context ? $sql_context : $sql_message;          my $sql = $context ? $sql_context : $sql_message;
262    
263          $sql .= " where message ilike ? or nick ilike ? " if ($args->{search});          sub check_date {
264          $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} });                  my $date = shift;
265          if ($args->{date}) {                  $date = eval { DateTime::Format::ISO8601->parse_datetime( $args->{date} )->ymd; };
                 my $date = eval { DateTime::Format::ISO8601->parse_datetime( $args->{date} )->ymd; };  
266                  if ( $@ ) {                  if ( $@ ) {
267                          warn "invalid date ", $args->{date}, $/;                          warn "invalid date ", $args->{date}, $/;
268                          $date = DateTime->now->ymd;                          $date = DateTime->now->ymd;
269                  }                  }
270                    return $date;
271            }
272    
273            $sql .= " where message ilike ? or nick ilike ? " if ($args->{search});
274            $sql .= " where id in (" . join(",", @{ $tags->{ $args->{tag} } }) . ") " if ($args->{tag} && $tags->{ $args->{tag} });
275            if ($args->{date}) {
276                  $sql .= " where date(time) = ? ";                  $sql .= " where date(time) = ? ";
277                  $args->{date} = $date;                  $args->{date} = check_date( $args->{date} );
278          }          }
279          $sql .= " order by log.time desc";          $sql .= " order by log.time desc";
280          $sql .= " limit " . $args->{limit} if ($args->{limit});          $sql .= " limit " . $args->{limit} if ($args->{limit});
# Line 284  sub get_from_log { Line 289  sub get_from_log {
289                  $sth->execute();                  $sth->execute();
290                  _log "tag '$tag' returned ", $sth->rows, " results ", $context || '';                  _log "tag '$tag' returned ", $sth->rows, " results ", $context || '';
291          } elsif (my $date = $args->{date}) {          } elsif (my $date = $args->{date}) {
292                  $sth->execute($date);                  $sth->execute( check_date($date) );
293                  _log "found ", $sth->rows, " messages for date $date ", $context || '';                  _log "found ", $sth->rows, " messages for date $date ", $context || '';
294          } else {          } else {
295                  $sth->execute();                  $sth->execute();
# Line 952  sub root_handler { Line 957  sub root_handler {
957                                  limit => $q->param('last') || $q->param('date') ? undef : 100,                                  limit => $q->param('last') || $q->param('date') ? undef : 100,
958                                  search => $search || undef,                                  search => $search || undef,
959                                  tag => $q->param('tag') || undef,                                  tag => $q->param('tag') || undef,
960                                  date => $q->param('date') || undef,                                  date => check_date( $q->param('date') ),
961                                  fmt => {                                  fmt => {
962                                          date => sub {                                          date => sub {
963                                                  my $date = shift || return;                                                  my $date = shift || return;

Legend:
Removed from v.66  
changed lines
  Added in v.67

  ViewVC Help
Powered by ViewVC 1.1.26