Revision d001c791
Von Sven Schöling vor fast 12 Jahren hinzugefügt
SL/Auth.pm | ||
---|---|---|
713 | 713 |
$main::lxdebug->leave_sub(); |
714 | 714 |
} |
715 | 715 |
|
716 |
sub active_session_ids { |
|
717 |
my $self = shift; |
|
718 |
my $dbh = $self->dbconnect; |
|
719 |
|
|
720 |
my $query = qq|SELECT id FROM auth.session|; |
|
721 |
|
|
722 |
my @ids = selectall_array_query($::form, $dbh, $query); |
|
723 |
|
|
724 |
return @ids; |
|
725 |
} |
|
726 |
|
|
716 | 727 |
sub expire_sessions { |
717 | 728 |
$main::lxdebug->enter_sub(); |
718 | 729 |
|
SL/BackgroundJob/CsvImport.pm | ||
---|---|---|
51 | 51 |
$self->{db_obj} = shift; |
52 | 52 |
|
53 | 53 |
$self->do_import; |
54 |
|
|
55 |
$self->cleanup; |
|
56 | 54 |
} |
57 | 55 |
|
58 | 56 |
sub do_import { |
... | ... | |
110 | 108 |
$self->{db_obj}->save; |
111 | 109 |
} |
112 | 110 |
|
113 |
sub cleanup { |
|
114 |
|
|
115 |
} |
|
116 |
|
|
117 | 111 |
1; |
118 | 112 |
|
119 | 113 |
__END__ |
SL/DB/CsvImportReport.pm | ||
---|---|---|
7 | 7 |
use SL::DBUtils; |
8 | 8 |
|
9 | 9 |
use SL::DB::MetaSetup::CsvImportReport; |
10 |
use SL::DB::Manager::CsvImportReport; |
|
10 | 11 |
|
11 | 12 |
__PACKAGE__->meta->add_relationships( |
12 | 13 |
rows => { |
... | ... | |
21 | 22 |
}, |
22 | 23 |
); |
23 | 24 |
|
24 |
__PACKAGE__->meta->make_manager_class; |
|
25 | 25 |
__PACKAGE__->meta->initialize; |
26 | 26 |
|
27 | 27 |
sub folded_rows { |
SL/DB/Manager/CsvImportReport.pm | ||
---|---|---|
1 |
package SL::DB::Manager::CsvImportReport; |
|
2 |
|
|
3 |
use strict; |
|
4 |
|
|
5 |
use base qw(SL::DB::Helper::Manager); |
|
6 |
|
|
7 |
sub object_class { 'SL::DB::CsvImportReport' } |
|
8 |
|
|
9 |
__PACKAGE__->make_manager_methods; |
|
10 |
|
|
11 |
sub cleanup { |
|
12 |
my ($self) = @_; |
|
13 |
|
|
14 |
$::auth->active_session_ids; |
|
15 |
|
|
16 |
# get expired reports |
|
17 |
my $objects = $self->get_all(query => [ |
|
18 |
session_id => [ |
|
19 |
not => [ $::auth->active_session_ids ] |
|
20 |
] |
|
21 |
]); |
|
22 |
|
|
23 |
$_->destroy for @$objects; |
|
24 |
|
|
25 |
# get reports for the active session that aren't the latest |
|
26 |
$objects = $self->get_all( |
|
27 |
query => [ session_id => $::auth->get_session_id, ], |
|
28 |
order_by => [ 'id' ], |
|
29 |
); |
|
30 |
|
|
31 |
# skip the last one |
|
32 |
for (0 .. $#$objects - 1) { |
|
33 |
$objects->[$_]->destroy; |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
1; |
|
38 |
|
Auch abrufbar als: Unified diff
cleanup Methode und Manager für CsvImportReport