source: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Stats.pm @ 1568

Last change on this file since 1568 was 1487, checked in by nanardon, 9 years ago

Run Stat with unexported objects active

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1package LATMOS::Accounts::Task::Stats;
2
3use strict;
4use warnings;
5use base qw(LATMOS::Accounts::Task);
6use LATMOS::Accounts;
7use LATMOS::Accounts::Log;
8use LATMOS::Accounts::Utils;
9
10=head1 NAME
11
12LATMOS::Accounts::Task::Stats - Store value to perform some statistics
13
14=head1 DESCRIPTION
15
16=cut
17
18sub init {
19    my ($self) = @_;
20    my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1);
21    my $labase = $self->{base} ? $LA->base($self->{base}) : $LA->base;
22    $labase && $labase->load or die "Cannot load base";
23
24    $self->{_la} = $LA;
25    $self->{_base} = $labase;
26
27    1;
28}
29
30sub needupd { 1 }
31
32sub run {
33    my ($self) = @_;
34
35    $self->{_base}->temp_switch_unexported(
36        sub {
37            foreach my $stat ($self->{_base}->list_objects('stat')) {
38                my $ostat = $self->{_base}->get_object('stat', $stat);
39                # Don't process unexported stat objects
40                $ostat->_get_attributes('unexported') and next;
41                if ($ostat->collect) {
42                    $self->{_base}->commit;
43                } else {
44                    $self->{_base}->rollback;
45                }
46            }
47        },
48        1
49    );
50
51    return 1;
52}
53
541;
55
56__END__
57
58=head1 SEE ALSO
59
60L<LATMOS::Accounts>, L<LATMOS::Accounts::Task>
61
62=head1 AUTHOR
63
64Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
65
66=head1 COPYRIGHT AND LICENSE
67
68Copyright (C) 2012 CNRS SA/CETP/LATMOS
69
70This library is free software; you can redistribute it and/or modify
71it under the same terms as Perl itself, either Perl version 5.10.0 or,
72at your option, any later version of Perl 5 you may have available.
73
74=cut
75
Note: See TracBrowser for help on using the repository browser.