def getMaxUpdatedAt(self, user): query = '''SELECT MAX(updated_at) FROM `order` WHERE user_id = {} '''.format(user['id']) try: conn = DatabaseHelper.getConnection() cur = conn.cursor() cur.execute(query) result = cur.fetchone() maxUpdatedAt = result[0] conn.close() if (maxUpdatedAt == None): return LazadaApiHelper.getFixedUpdatedAfterForCronJob(), None; return maxUpdatedAt, None except Exception as ex: return None, '''User: {}-{}, Get-Max-Updated-At: {}'''.format(user['username'], user['id'], str(ex))
def initDefaultConstantValue(self): users = userDao.getAll() if (users == None): return # Insert Product Offset for user in users: # Check constant exist isProductOffsetExist, exception = constantDao.isConstantExist( user, ConstantConfig.PRODUCT_LAST_REQUEST) if (exception != None): print(exception) elif (isProductOffsetExist == False): fixStartDatetime = LazadaApiHelper.getFixedUpdatedAfterForCronJob( ) exception = constantDao.insertConstant( user, ConstantConfig.PRODUCT_LAST_REQUEST, fixStartDatetime) if (exception != None): print(exception)