Changeset 1937 for trunk


Ignore:
Timestamp:
01/18/17 12:09:43 (7 years ago)
Author:
nanardon
Message:

Add retention attr to stat (delete old entries)

Location:
trunk/LATMOS-Accounts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Stat.pm

    r1933 r1937  
    88use base qw(LATMOS::Accounts::Bases::Sql::objects); 
    99use LATMOS::Accounts::I18N; 
     10 
     11use DateTime; 
    1012 
    1113our $VERSION = (q$Rev$ =~ /^Rev: (\d+) /)[0]; 
     
    4547            display => { }, 
    4648            delay => { }, 
     49            retention => { }, 
    4750            lastStatId => { }, 
    4851            needRun => { 
     
    184187    my ($self) = @_; 
    185188 
     189    if (my $retention = $self->_get_attributes('retention')) { 
     190        my $limit = DateTime->now->subtract(days => $retention); 
     191 
     192        my $clean = $self->db->prepare( 
     193            q{ DELETE FROM statsentry where tstamp < ? } 
     194        ); 
     195        $clean->execute($limit->iso8601); 
     196    } 
     197 
    186198    my $otype = $self->_get_attributes('otype') or return; 
    187199    my $attribute = $self->_get_attributes('attribute') or return; 
  • trunk/LATMOS-Accounts/man/man8/latmos-accounts-base-sql.pod

    r1934 r1937  
    327327The number of day between two run 
    328328 
     329=head4 retention 
     330 
     331If set, the duration in days after which stats value must deleted 
Note: See TracChangeset for help on using the changeset viewer.