X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/b2930e37cd4bfd276be6c785e1cd7fff0f503aef..d001c791676ec85371465f557cf21e72b09319a4:/SL/DB/Manager/CsvImportReport.pm diff --git a/SL/DB/Manager/CsvImportReport.pm b/SL/DB/Manager/CsvImportReport.pm new file mode 100644 index 000000000..370a6c97f --- /dev/null +++ b/SL/DB/Manager/CsvImportReport.pm @@ -0,0 +1,38 @@ +package SL::DB::Manager::CsvImportReport; + +use strict; + +use base qw(SL::DB::Helper::Manager); + +sub object_class { 'SL::DB::CsvImportReport' } + +__PACKAGE__->make_manager_methods; + +sub cleanup { + my ($self) = @_; + + $::auth->active_session_ids; + + # get expired reports + my $objects = $self->get_all(query => [ + session_id => [ + not => [ $::auth->active_session_ids ] + ] + ]); + + $_->destroy for @$objects; + + # get reports for the active session that aren't the latest + $objects = $self->get_all( + query => [ session_id => $::auth->get_session_id, ], + order_by => [ 'id' ], + ); + + # skip the last one + for (0 .. $#$objects - 1) { + $objects->[$_]->destroy; + } +} + +1; +