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

Last change on this file since 1930 was 1922, checked in by nanardon, 7 years ago

add some debug message, update dpmt for manager

File size: 1.3 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
55foreach my $group ($labase->search_objects('group', 'sutype=dpmt')) {
56    print "Updating group $group\n";
57    my $ogroup = $labase->get_object('group', $group) or next;
58    $ogroup->_update_employment_manager;
59}
60
61$labase->PopulateDynData;
62
63if ($nocommit) {
64    $labase->rollback;
65} else {
66    $labase->commit;
67}
68print "Process terminated successfully\n";
Note: See TracBrowser for help on using the repository browser.