From f4ebe7536ff5baa0beabf6e3340000594ab9cb49 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 20 Feb 2013 22:36:23 -0500 Subject: [PATCH] Remove Timezone Dependency Formerly, the initial record pull was based on the current time of the server minus five minutes. This caused timing issues, specifically in the case where the database server and dbmonitor server had different timezones set. The initial record is now grabbed based on the timestamp of the last record insertted into the table. If there are no records in the database 0000-01-01 00:00:00 is used as the initial timestamp. --- dbmonitor.coffee | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbmonitor.coffee b/dbmonitor.coffee index 902e3a1..335928d 100644 --- a/dbmonitor.coffee +++ b/dbmonitor.coffee @@ -10,7 +10,10 @@ db = require('mysql-native').createTCPClient(database.host, database.port) db.auth database.database, database.username, database.password db.auto_prepare = true -checkDate = moment().add('minutes', -5) +checkDate = moment('0000-01-01 00:00:00', 'YYYY-MM-DD HH:mm:ss') +query = "SELECT " + application.timestamp_column + " FROM `print_jobs` ORDER BY " + application.timestamp_column + " DESC LIMIT 1" +db.query(query).addListener 'row', (start) -> + checkDate = moment(start[application.timestamp_column], 'YYYY-MM-DD HH:mm:ss') getDatabaseUpdates = () -> query = "SELECT " + application.timestamp_column + "," + application.columns.join(',') + " FROM " + application.table + " WHERE " + application.where + " AND " + application.timestamp_column + " > '" + checkDate.format('YYYY-MM-DD HH:mm:ss') + "'"