From e7d69dff9cfc4432fbe29cc7891f91f01f182775 Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" Date: Wed, 15 Mar 2006 18:22:35 +0000 Subject: [PATCH] Keep last 24 hours of data on ops, as a sliding window, pushed every hour from crontab. --- pelab/db/pelab_dbpush.in | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pelab/db/pelab_dbpush.in b/pelab/db/pelab_dbpush.in index f281b4fbe..409068494 100644 --- a/pelab/db/pelab_dbpush.in +++ b/pelab/db/pelab_dbpush.in @@ -148,6 +148,12 @@ if (!defined($lastidx)) { unlink("${tempfile}.pair_data") if (-e "${tempfile}.pair_data"); +# +# Compute the cutoff age; We leave MAXAGE old entries here, and ship +# the rest over to the DP. +# +my $cutoffage = (time() - $MAXAGE) * 1.0; + # # Must lock the table of course # @@ -157,7 +163,7 @@ DBQueryFatal("lock tables pair_data write"); # Grab all of the new entries and store to the file # DBQueryFatal("select * from pair_data ". - "where idx > $lastidx " . + "where idx > $lastidx and unixstamp < $cutoffage ". "into outfile '${tempfile}.pair_data' ". "fields terminated by ' '"); @@ -166,7 +172,7 @@ DBQueryFatal("select * from pair_data ". # $query_result = DBQueryFatal("select idx from pair_data ". - "where idx > $lastidx " . + "where idx > $lastidx and unixstamp < $cutoffage " . "order by idx desc limit 1"); # Save for later. $lastidx = $query_result->fetchrow_array(); -- GitLab