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

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

No acl to collect stat

  • Property svn:executable set to *
File size: 1.4 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    foreach my $stat ($self->{_base}->list_objects('stat')) {
36        my $ostat = $self->{_base}->get_object('stat', $stat);
37        # Don't process unexported stat objects
38        $ostat->_get_attributes('exported') or next;
39        if ($ostat->collect) {
40            $self->{_base}->commit;
41        } else {
42            $self->{_base}->rollback;
43        }
44    }
45
46    return 1;
47}
48
491;
50
51__END__
52
53=head1 SEE ALSO
54
55L<LATMOS::Accounts>, L<LATMOS::Accounts::Task>
56
57=head1 AUTHOR
58
59Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
60
61=head1 COPYRIGHT AND LICENSE
62
63Copyright (C) 2012 CNRS SA/CETP/LATMOS
64
65This library is free software; you can redistribute it and/or modify
66it under the same terms as Perl itself, either Perl version 5.10.0 or,
67at your option, any later version of Perl 5 you may have available.
68
69=cut
70
Note: See TracBrowser for help on using the repository browser.