source: trunk/LATMOS-Accounts/bin/la-sql-recompute @ 1907

Last change on this file since 1907 was 1855, checked in by nanardon, 8 years ago

Add to to recompute data

File size: 1.1 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts;
6use Getopt::Long;
7use Pod::Usage;
8
9=head1 NAME
10
11    la-sql-recompute - Update computed attribute
12
13=head1 SYNOPSIS
14
15    la-sql-upgrade [options]
16
17=cut
18
19GetOptions(
20    'c|config=s'     => \my $config,
21    'b|base=s'       => \my $base,
22    'no-commit'      => \my $nocommit,
23    'v|verbose'      => \my $verbose,
24    'h|help'         => sub { pod2usage(1); },
25) or pod2usage();
26
27=head1 OPTIONS
28
29=over 4
30
31=item -c|--config configdir
32
33Use this configuration directory instead of the default one.
34
35=item -b|--base basename
36
37Query this specific base instead of the default one.
38
39=back
40
41=cut
42
43$| = 1; # autoflush
44
45my $LA = LATMOS::Accounts->new($config, noacl => 1);
46my $labase = $LA->base($base);
47$labase->wexported(1);
48
49foreach my $user ($labase->list_objects('user')) {
50    print "Updating user $user\n";
51    my $ouser = $labase->get_object('user', $user) or next;
52    $ouser->computeEmploymentDate();
53}
54
55$labase->PopulateDynData;
56
57if ($nocommit) {
58    $labase->rollback;
59} else {
60    $labase->commit;
61}
62print "Process terminated successfully\n";
Note: See TracBrowser for help on using the repository browser.