Changeset 238


Ignore:
Timestamp:
12/30/10 18:02:30 (13 years ago)
Author:
nanardon
Message:
  • get statistic about Chat request
Location:
server/trunk/web/lib/Sophie/Controller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Chat.pm

    r191 r238  
    4949    } 
    5050} 
     51 
     52 
     53sub update_statistic : Private { 
     54    my ($self, $c, $cmd) = @_; 
     55 
     56    $c->model('Base::ChatStat')->search( 
     57        { 
     58            -nest => \[ 
     59            "day < now() - ?::interval", 
     60            [ plain_text => "365 days" ], 
     61        ], 
     62        } 
     63    )->delete; 
     64    my $stat = $c->model('Base::ChatStat')->find_or_create({ 
     65        cmd => $cmd, 
     66        day => 'now()', 
     67    }); 
     68    $stat->update({ count => ($stat->count || 0) + 1 }); 
     69    $c->model('Base')->storage->dbh->commit; 
     70} 
     71 
    5172 
    5273sub message : XMLRPC { 
  • server/trunk/web/lib/Sophie/Controller/Chat/Cmd.pm

    r237 r238  
    2929sub end : Private { 
    3030    my ($self, $c ) = @_; 
     31     
     32    $c->forward('/chat/update_statistic', [ ($c->action =~ /([^\/]+)$/)[0] ]); 
     33 
    3134    my $reqspec = $c->req->arguments->[0]; 
    3235    $reqspec->{max_line} ||= 4; 
Note: See TracChangeset for help on using the changeset viewer.