1 package SL::Controller::BackgroundJobHistory;
5 use parent qw(SL::Controller::Base);
7 use SL::Controller::Helper::GetModels;
8 use SL::DB::BackgroundJobHistory;
10 use SL::Locale::String;
11 use SL::System::TaskServer;
13 use Rose::Object::MakeMethods::Generic
15 scalar => [ qw(history filter_summary) ],
16 'scalar --get_set_init' => [ qw(task_server models) ],
19 __PACKAGE__->run_before('check_auth');
20 __PACKAGE__->run_before('add_stylesheet');
21 __PACKAGE__->run_before('check_task_server');
30 $self->make_filter_summary;
32 $self->render('background_job_history/list',
33 title => $::locale->text('Background job history'),
34 ENTRIES => $self->models->get,
35 MODELS => $self->models);
41 my $back_to = $::form->{back_to} || $self->url_for(action => 'list');
43 $self->history(SL::DB::BackgroundJobHistory->new(id => $::form->{id})->load);
44 $self->render('background_job_history/show',
45 title => $::locale->text('View background job execution result'),
54 $::auth->assert('admin');
61 sub init_task_server {
62 return SL::System::TaskServer->new;
65 sub check_task_server {
67 flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
71 $::request->{layout}->use_stylesheet('background_jobs.css');
74 sub make_filter_summary {
77 my $filter = $::form->{filter} || {};
79 [ "package_name:substr::ilike", $::locale->text('Package name') ],
80 [ "result:substr::ilike", $::locale->text('Result') ],
81 [ "error:substr::ilike", $::locale->text('Error') ],
82 [ "run_at:date::ge", $::locale->text('Run at') . " " . $::locale->text('From Date') ],
83 [ "run_at:date::le", $::locale->text('Run at') . " " . $::locale->text('To Date') ],
86 my @filter_strings = grep { $_ }
87 map { $filter->{ $_->[0] } ? $_->[1] . ' ' . $filter->{ $_->[0] } : undef }
91 failure => $::locale->text('failed'),
92 success => $::locale->text('succeeded'),
94 push @filter_strings, $status{ $filter->{'status:eq_ignore_empty'} } if $filter->{'status:eq_ignore_empty'};
96 $self->filter_summary(join(', ', @filter_strings));
102 SL::Controller::Helper::GetModels->new(
105 package_name => t8('Package name'),
106 run_at => t8('Run at'),
107 status => t8('Execution status'),
108 result => t8('Result'),
109 error => t8('Error'),