sharee.bike/copri4/main/src/scripts/requested_timeout.pl

76 lines
1.7 KiB
Perl
Raw Normal View History

2021-12-30 12:05:56 +01:00
#!/usr/bin/perl
#
# SPDX-License-Identifier: AGPL-3.0-or-later
# Copyright (c) Rainer Gümpelein, TeilRad GmbH
2021-12-30 12:05:56 +01:00
#
#set availabel if requested > 15min
#
#Example
#./src/scripts/requested_timeout.pl shareedms-operator
2021-12-30 12:05:56 +01:00
#
#
use vars qw($syshost);
BEGIN {
$syshost = $ARGV[0] || die;
}
2022-01-09 18:31:20 +01:00
use lib "/var/www/copri-bike/$syshost/src";
2021-12-30 12:05:56 +01:00
use strict;
use warnings;
use POSIX;
use CGI ':standard';
use Lib::Config;
use Mod::DBtank;
use Data::Dumper;
my $q = new CGI;
my $cf = new Config;
my %varenv = $cf->envonline("$syshost");
my $dbt = new DBtank;
my $lang = "de";
my $now_dt = strftime "%Y-%m-%d %H:%M:%S", localtime;
my $dbh = "";
2022-06-10 06:47:18 +02:00
my $interval_min = "15";
$interval_min = $ARGV[1] if($ARGV[1] && $ARGV[1] =~ /^\d+$/);
2021-12-30 12:05:56 +01:00
#set available if requestes older than 15 minute
my $return={};
my $pref = {
table => "contenttranspos",
fetch => "all",
keyfield => "c_id",
int10 => "2",
owner => "!=::199",#don't select LV api requested bikes
2022-06-10 06:47:18 +02:00
start_time => "<=::(now() - interval '$interval_min minutes')",
2021-12-30 12:05:56 +01:00
};
my $record_cp = $dbt->fetch_tablerecord($dbh,$pref);
my $update_cp = {
table => "contenttranspos",
int10 => "1",
2022-06-02 10:34:03 +02:00
owner_end => "172",
mtime => "now()",
2021-12-30 12:05:56 +01:00
};
my $update_cc = {
table => "content",
int10 => "1",
};
my $rows = 0;
foreach my $id (sort { $record_cp->{$a}->{c_id} <=> $record_cp->{$b}->{c_id} } keys (%$record_cp)){
my $record = { c_id => 0 };
$record->{c_id} = $record_cp->{$id}->{c_id};
#contenttranspos
$rows = $dbt->update_record($dbh,$update_cp,$record);
if($rows > 0 && $record_cp->{$id}->{cc_id}){
$record->{c_id} = $record_cp->{$id}->{cc_id};
#content
$dbt->update_record($dbh,$update_cc,$record);
}
}
1;