Fix time between batches count

This commit is contained in:
M1ha 2018-12-19 12:58:34 +05:00
parent 36123db73e
commit 13b67ed77a
2 changed files with 3 additions and 3 deletions

View File

@ -231,7 +231,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
if last_sync_time is None:
return True
return (last_sync_time - datetime.datetime.now()).total_seconds() >= cls.get_sync_delay()
return (datetime.datetime.now() - last_sync_time).total_seconds() >= cls.get_sync_delay()
class ClickHouseMultiModel(ClickHouseModel):

View File

@ -26,5 +26,5 @@ class ClickHouseModelTest(TestCase):
# Time has passed
sync_delay = ClickHouseTestModel.get_sync_delay()
self.storage.set_last_sync_time(ClickHouseTestModel.get_import_key(),
datetime.datetime.now() - datetime.timedelta(seconds=sync_delay))
self.assertFalse(ClickHouseTestModel.need_sync())
datetime.datetime.now() - datetime.timedelta(seconds=sync_delay + 1))
self.assertTrue(ClickHouseTestModel.need_sync())