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->setup_list_action_bar;
33 $self->render('background_job_history/list',
34 title => $::locale->text('Background job history'),
35 ENTRIES => $self->models->get,
36 MODELS => $self->models);
42 my $back_to = $::form->{back_to} || $self->url_for(action => 'list');
44 $self->history(SL::DB::BackgroundJobHistory->new(id => $::form->{id})->load);
45 $self->setup_show_action_bar;
46 $self->render('background_job_history/show',
47 title => $::locale->text('View background job execution result'),
56 $::auth->assert('admin');
63 sub init_task_server {
64 return SL::System::TaskServer->new;
67 sub check_task_server {
69 flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
73 $::request->{layout}->use_stylesheet('background_jobs.css');
76 sub make_filter_summary {
79 my $filter = $::form->{filter} || {};
81 [ "package_name:substr::ilike", $::locale->text('Package name') ],
82 [ "result:substr::ilike", $::locale->text('Result') ],
83 [ "error:substr::ilike", $::locale->text('Error') ],
84 [ "run_at:date::ge", $::locale->text('Run at') . " " . $::locale->text('From Date') ],
85 [ "run_at:date::le", $::locale->text('Run at') . " " . $::locale->text('To Date') ],
88 my @filter_strings = grep { $_ }
89 map { $filter->{ $_->[0] } ? $_->[1] . ' ' . $filter->{ $_->[0] } : undef }
93 failure => $::locale->text('failed'),
94 success => $::locale->text('succeeded'),
96 push @filter_strings, $status{ $filter->{'status:eq_ignore_empty'} } if $filter->{'status:eq_ignore_empty'};
98 $self->filter_summary(join(', ', @filter_strings));
104 SL::Controller::Helper::GetModels->new(
107 package_name => t8('Package name'),
108 run_at => t8('Run at'),
109 status => t8('Execution status'),
110 result => t8('Result'),
111 error => t8('Error'),
116 sub setup_list_action_bar {
119 for my $bar ($::request->layout->get('actionbar')) {
122 t8('Server control'),
123 link => $self->url_for(controller => 'TaskServer', action => 'show'),
127 link => $self->url_for(controller => 'BackgroundJob', action => 'list'),
133 sub setup_show_action_bar {
136 for my $bar ($::request->layout->get('actionbar')) {
140 link => $self->url_for(action => 'list'),