예제 #1
0
 def test_sqlite_set(self):
     user = "******"
     persistence.postgres_set_sqlite(user, 1)
     date_one = persistence.postgres_lookup_sqlite_last_modified(user)
     persistence.postgres_set_sqlite(user, 2)
     date_two = persistence.postgres_lookup_sqlite_last_modified(user)
     version = persistence.postgres_lookup_sqlite_version(user)
     self.assertTrue(date_two > date_one)
     self.assertTrue(version == 2)
예제 #2
0
    def needs_sync(self):
        try:
            self.last_sync = persistence.postgres_lookup_sqlite_last_modified(self.username)
        except:
            logger.exception("Unable to get last sync for usertime for user %s " % self.username)
            return True

        current_time = datetime.utcnow()
        elapsed = current_time - self.last_sync
        minutes_elapsed = divmod(elapsed.days * 86400 + elapsed.seconds, 60)[0]
        return minutes_elapsed > settings.SQLITE_STALENESS_WINDOW
예제 #3
0
    def needs_sync(self):
        try:
            self.last_sync = persistence.postgres_lookup_sqlite_last_modified(
                self.username)
        except:
            logger.exception(
                "Unable to get last sync for usertime for user %s " %
                self.username)
            return True

        current_time = datetime.utcnow()
        elapsed = current_time - self.last_sync
        minutes_elapsed = divmod(elapsed.days * 86400 + elapsed.seconds, 60)[0]
        return minutes_elapsed > settings.SQLITE_STALENESS_WINDOW