PartImport: check_existing etwas optimiert, spart bei Testimports gut 40% Zeit.
[kivitendo-erp.git] / SL / Controller / BackgroundJobHistory.pm
1 package SL::Controller::BackgroundJobHistory;
2
3 use strict;
4
5 use parent qw(SL::Controller::Base);
6
7 use SL::Controller::Helper::GetModels;
8 use SL::Controller::Helper::Paginated;
9 use SL::Controller::Helper::Sorted;
10 use SL::DB::BackgroundJobHistory;
11 use SL::Helper::Flash;
12 use SL::Locale::String;
13 use SL::System::TaskServer;
14
15 use Rose::Object::MakeMethods::Generic
16 (
17   scalar                  => [ qw(history) ],
18   'scalar --get_set_init' => [ qw(task_server) ],
19 );
20
21 __PACKAGE__->run_before('check_auth');
22 __PACKAGE__->run_before('add_stylesheet');
23 __PACKAGE__->run_before('check_task_server');
24
25 __PACKAGE__->make_paginated(ONLY => [ qw(list) ]);
26
27 __PACKAGE__->make_sorted(
28   ONLY         => [ qw(list) ],
29
30   package_name => t8('Package name'),
31   run_at       => t8('Run at'),
32   status       => t8('Execution status'),
33   result       => t8('Result'),
34   error        => t8('Error'),
35 );
36
37 #
38 # actions
39 #
40
41 sub action_list {
42   my ($self) = @_;
43
44   $self->render('background_job_history/list',
45                 title   => $::locale->text('Background job history'),
46                 ENTRIES => $self->get_models);
47 }
48
49 sub action_show {
50   my ($self) = @_;
51
52   my $back_to = $::form->{back_to} || $self->url_for(action => 'list');
53
54   $self->history(SL::DB::BackgroundJobHistory->new(id => $::form->{id})->load);
55   $self->render('background_job_history/show',
56                 title   => $::locale->text('View background job execution result'),
57                 back_to => $back_to);
58 }
59
60 #
61 # filters
62 #
63
64 sub check_auth {
65   $::auth->assert('admin');
66 }
67
68 #
69 # helpers
70 #
71
72 sub init_task_server {
73   return SL::System::TaskServer->new;
74 }
75
76 sub check_task_server {
77   my ($self) = @_;
78   flash('warning', $::locale->text('The task server does not appear to be running.')) if !$self->task_server->is_running;
79 }
80
81 sub add_stylesheet {
82   $::request->{layout}->use_stylesheet('lx-office-erp/background_jobs.css');
83 }
84
85 1;