changeset 373:bc7746ca622e

fetch_weather: Implement purge_threshold setting.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 30 Jan 2016 00:55:43 +0200
parents 9dd4d2e3a4ac
children 26b7963e7fbd
files config.fetch_weather.example fetch_weather.pl
diffstat 2 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/config.fetch_weather.example	Sat Jan 30 00:28:14 2016 +0200
+++ b/config.fetch_weather.example	Sat Jan 30 00:55:43 2016 +0200
@@ -4,6 +4,17 @@
 ###
 
 ##
+## Purge time threshold for old/obsolete records.
+## Fetch_weather stores data into a cache file, which
+## also keeps older records as sometimes weather stations
+## do not report reliably. However, too old records
+## need to be purged. This setting sets the threshold
+## time in MINUTES (default is 60 minutes)
+##
+purge_threshold = 60
+
+
+##
 ## Enable/disable data scraping from Tiehallinto's WWW-pages
 ##
 opt_tiehallinto = 1
--- a/fetch_weather.pl	Sat Jan 30 00:28:14 2016 +0200
+++ b/fetch_weather.pl	Sat Jan 30 00:55:43 2016 +0200
@@ -488,12 +488,15 @@
 
 
 ###
-### Purge very old entries
+### Purge very old entries, default to 60 minutes
 ###
 my $wqtime = time();
+my $purge = opt_get_int("purge_threshold");
+$purge = 60 if ($purge <= 0);
+
 foreach my $key (keys %$weatherdata)
 {
-  if ($wqtime - $weatherdata->{$key}[1] > (60*60*6))
+  if ($wqtime - $weatherdata->{$key}[1] > (60 * $purge))
   {
     delete $$weatherdata{$key};
   }