From 4e3fd63439e48b0a21ac25eef0b1757d2af6b79d Mon Sep 17 00:00:00 2001 From: arjen Date: Fri, 14 Feb 2003 06:35:09 +0000 Subject: [PATCH] Maintain the last notification identifier --- src/gcm_daemon/gcm_daemon.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/gcm_daemon/gcm_daemon.php b/src/gcm_daemon/gcm_daemon.php index dc97a0f..b9d8bcb 100755 --- a/src/gcm_daemon/gcm_daemon.php +++ b/src/gcm_daemon/gcm_daemon.php @@ -20,7 +20,7 @@ */ -// $Id: gcm_daemon.php,v 1.6 2003-02-13 08:39:12 arjen Exp $ +// $Id: gcm_daemon.php,v 1.7 2003-02-14 06:35:09 arjen Exp $ ini_set('include_path', '.:./classes:../phpclasses'); @@ -37,7 +37,7 @@ require_once "gnucomo.process_log.php"; $project_name = "gnucomo"; //name of the entire project $app_name = "gcm_daemon"; //name of the application running $developrelease = "TRUE"; //Indicates if special debug settings are needed -$db_version = 28; //The db_version indicates what the level of +$db_version = 30; //The db_version indicates what the level of //the database should be. If the database is //old an update will be generated. $gcmd_version = 3; //This value indicates the active version of the gcm_daemon, @@ -269,11 +269,13 @@ function notificationstats () { $local_sql = "SELECT MAX(notificationid) FROM notification " . "WHERE notificationid > CAST ('" . $last_notification . "' AS BIGINT)"; $dbms->query($local_sql); - + //Only process data if there are new notifications if ($dbms->fetch_row() == "TRUE") { + if (intval($dbms->db_result_row[0])>0) { $local_upper = $dbms->db_result_row[0] + 1; - $local_sql = "SELECT COUNT(objectid), objectid FROM notification " . + $local_max = $dbms->db_result_row[0]; + $local_sql = "SELECT COUNT(objectid), objectid FROM notification " . "WHERE notificationid > CAST ('" . $last_notification ."' AS BIGINT) " . "AND notificationid < CAST ('" . $local_upper . "' AS BIGINT) GROUP BY objectid"; @@ -286,13 +288,13 @@ function notificationstats () { $local_sql = "UPDATE object SET notification_count = notification_count + " . $dbms->db_result_row[0] . " WHERE objectid = '" . $dbms->db_result_row[1] . "'"; $local_dbms->query($local_sql); - } - } + } - $local_sql = "UPDATE db_value SET setting_value = '" . $local_upper . - "' WHERE setting = 'last_notification'"; - $dbms->query($local_sql); - + $local_sql = "UPDATE db_value SET setting_value = '" . $local_max . + "' WHERE setting = 'last_notification'"; + $dbms->query($local_sql); + } + } } ?> -- 2.11.0