#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

BEGIN {
    use FindBin qw($Bin); # warn $Bin;
    use lib (
        "$Bin/../../../lib",
        '/home/raj/perl5/lib/perl5',
    );
}

use constant DELTA => 6; # months since last login to inactivate account

use LIMS::Local::ScriptHelpers;
my $tools = LIMS::Local::ScriptHelpers->new();

# get tools from LIMS::Local::ScriptHelpers:
my $sql_lib = $tools->sql_lib();
my $dbix    = $tools->dbix();

# get sql statments:
my $sql = $sql_lib->retr( 'expire_user_accounts' ); # warn $sql; warn DELTA; exit;

my $i = 0; # numerical return from dbh->do()

# execute query:
$i += $dbix->dbh->do($sql, undef, DELTA); # warn Dumper $i;

if ($i) {
	my $filename = $tools->script_filename;
	print "$filename inactivated $i accounts\n";
}
