Ignore:
Timestamp:
02/25/19 16:40:07 (5 years ago)
Author:
nanardon
Message:

Add module to recompute object value in background

Location:
trunk/LATMOS-Accounts/lib/LATMOS/Accounts
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/upgrade.pm

    r2204 r2220  
    11841184            ], 
    11851185        }, 
     1186        { 
     1187            ver => 30, 
     1188            recompute => 1, 
     1189        }, 
    11861190    ); 
    11871191 
    11881192    my $dbi = $self->{_db}; 
     1193 
     1194    my $NeedRecompute = 0; 
    11891195 
    11901196    foreach my $maj (@updates) { 
     
    11931199        } 
    11941200        $self->log(LA_NOTICE, 'Switching to schema revision: ' . $maj->{ver} . "\n"); 
    1195         foreach my $sql (@{ $maj->{sql} }) { 
     1201        foreach my $sql (@{ $maj->{sql} || []}) { 
    11961202            { 
    11971203                my $sqlv = $sql; 
     
    12031209                return; 
    12041210            }; 
     1211 
     1212        } 
     1213        if ($maj->{recompute}) { 
     1214            $NeedRecompute = 1; 
    12051215        } 
    12061216 
     
    12121222            $maj->{ver}, 'schema_version' 
    12131223        ); 
     1224    } 
     1225 
     1226    if ( $NeedRecompute ) { 
     1227        $self->set_global_value('NeedRecomputeObject', 'Yes'); 
    12141228    } 
    12151229 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/SyncManager.pm

    r2034 r2220  
    3838    }; 
    3939 
    40     foreach my $section (qw(basessynchro refreshexpired updatedyndata)) { 
     40    foreach my $section (qw(update basessynchro refreshexpired updatedyndata)) { 
    4141        if ( !grep { 
    4242            lc($ini->val($_, 'type', '')) eq $section 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Update.pm

    r2219 r2220  
    1 package LATMOS::Accounts::Task::Updatedyndata; 
     1package LATMOS::Accounts::Task::Update; 
    22 
    33use strict; 
     
    1414=head1 DESCRIPTION 
    1515 
    16 Some base doesn't handle accounts expiration. One way to do it is to synchronize 
    17 user with value denying login (wrong UNIX shell, password entry set to false, 
    18 ...). 
    19  
    20 For performance issue, objects are not written at each synchronisation, only 
    21 when they changes. 
    22  
    23 This module find expired user and refresh modification time to ensure 
    24 propagation to other database. 
     16This module update in the background objects that need some value to be recompute 
    2517 
    2618=cut 
    2719 
    28 # Every 10 minutes 
    29 sub runDelay { 5 * 60 } 
    3020 
    3121sub init { 
     
    4434    my ($self) = @_; 
    4535 
    46     $self->{_base}->PopulateDynData; 
     36    if ($self->{_base}->get_global_value('NeedRecomputeObject')) { 
     37        $self->{_base}->log(LA_INFO, "NeedRecomputeObject detected, recomputing objects"); 
     38    } else { 
     39        return 1; 
     40    } 
     41 
     42    foreach my $otype (qw(user)) { 
     43        foreach my $name ($self->{_base}->listRealObjects($otype)) { 
     44            my $object = $self->{_base}->get_object($otype, $name); 
     45            $object->PostSetAttribute(); 
     46            $self->{_base}->commit; 
     47        } 
     48    } 
     49 
     50    $self->{_base}->del_global_value('NeedRecomputeObject'); 
     51    $self->{_base}->commit; 
    4752 
    4853    1; 
  • trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Updatedyndata.pm

    r2189 r2220  
    2626=cut 
    2727 
    28 # Every 10 minutes 
     28# Every 5 minutes 
    2929sub runDelay { 5 * 60 } 
    3030 
Note: See TracChangeset for help on using the changeset viewer.