Line # Revision Author
1 303 ahitrov #!/usr/bin/perl
2
3 use strict;
4 use warnings "all";
5 use locale;
6
7 use FindBin;
8 BEGIN {
9 require "$FindBin::RealBin/../lib/Modules.pm";
10 }
11
12 use Contenido::Globals;
13 use Contenido::Init;
14 use ErrorTee;
15 use PidFile;
16
17
18 # begin
19 Contenido::Init->init();
20
21 my $keeper_module = $state->project.'::Keeper';
22 $keeper = $keeper_module->new($state);
23
24 #PidFile->new($keeper, compat=>1); # db-based locking (run only on one host)
25 #PidFile->new($keeper, compat=>1, per_host=>1); # db-based locking (run on whole cluster)
26
27 ############################################
28 # please use:
29 # $state->{log_dir} for logging
30 # $state->{tmp_dir} for temporary files
31 ###########################################
32 my $SALES_TIMEOUT = 3600;
33 my $VAULT_TIMEOUT = 10800;
34
35 my $now = Contenido::DateTime->new;
36 my $request = "UPDATE orders SET manager_id = 0 WHERE status = 1 AND mtime < (CURRENT_DATE - '$SALES_TIMEOUT seconds'::INTERVAL)";
37 my $sql = $keeper->SQL->prepare( $request );
38 $sql->execute();
39 $sql->finish();
40
41 $request = "UPDATE orders SET vault_id = 0 WHERE status = 2 AND mtime < (CURRENT_DATE - '$VAULT_TIMEOUT seconds'::INTERVAL)";
42 $sql = $keeper->SQL->prepare( $request );
43 $sql->execute();
44 $sql->finish();