From af44c6d190f91cf582a0a4db595b1f166395c44d Mon Sep 17 00:00:00 2001 From: Eric House Date: Sun, 15 Sep 2013 12:54:47 -0700 Subject: [PATCH] only append to mtimes when appending a new devid --- xwords4/relay/dbmgr.cpp | 18 +++++++++++------- xwords4/relay/dbmgr.h | 6 +++--- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/xwords4/relay/dbmgr.cpp b/xwords4/relay/dbmgr.cpp index 96d497189..730aa0c87 100644 --- a/xwords4/relay/dbmgr.cpp +++ b/xwords4/relay/dbmgr.cpp @@ -439,7 +439,7 @@ DBMgr::ReregisterDevice( DevIDRelay relayID, const DevID* host, "devids = array_prepend('%s', devids), ", host->m_devIDType, host->m_devIDString.c_str() ); - formatUpdate( query, desc, clientVersion, model, osVers, relayID ); + formatUpdate( query, true, desc, clientVersion, model, osVers, relayID ); execSql( query ); } @@ -459,7 +459,7 @@ DBMgr::UpdateDevice( DevIDRelay relayID, const char* const desc, if ( exists ) { StrWPF query; query.printf( "UPDATE " DEVICES_TABLE " SET " ); - formatUpdate( query, desc, clientVersion, model, osVers, relayID ); + formatUpdate( query, false, desc, clientVersion, model, osVers, relayID ); execSql( query ); } return exists; @@ -472,12 +472,16 @@ DBMgr::UpdateDevice( DevIDRelay relayID ) } void -DBMgr::formatUpdate( StrWPF& query, const char* const desc, int clientVersion, - const char* const model, const char* const osVers, - DevIDRelay relayID ) +DBMgr::formatUpdate( StrWPF& query, bool append, const char* const desc, + int clientVersion, const char* const model, + const char* const osVers, DevIDRelay relayID ) { - // query.printf( "mtimes=array_prepend('now', mtimes)" ); // FIXME: too many - query.printf( "mtimes[1]='now'" ); + if ( append ) { + query.printf( "mtimes=array_prepend('now', mtimes)" ); // FIXME: too many + } else { + query.printf( "mtimes[1]='now'" ); + } + if ( NULL != desc && '\0' != desc[0] ) { query.printf( ", clntVers=%d, versDesc='%s'", clientVersion, desc ); } diff --git a/xwords4/relay/dbmgr.h b/xwords4/relay/dbmgr.h index ddaa1b9f2..e55de7562 100644 --- a/xwords4/relay/dbmgr.h +++ b/xwords4/relay/dbmgr.h @@ -159,9 +159,9 @@ class DBMgr { bool nullConnnameOK ); int CountStoredMessages( const char* const connName, int hid ); bool UpdateDevice( DevIDRelay relayID ); - void formatUpdate( StrWPF& query, const char* const desc, int clientVersion, - const char* const model, const char* const osVers, - DevIDRelay relayID ); + void formatUpdate( StrWPF& query, bool append, const char* const desc, + int clientVersion, const char* const model, + const char* const osVers, DevIDRelay relayID ); PGconn* getThreadConn( void ); void clearThreadConn();