mirror of
https://github.com/carrotquest/django-clickhouse.git
synced 2024-11-24 18:13:46 +03:00
Fix need_sync period
This commit is contained in:
parent
2d2ec9c055
commit
13a226501f
|
@ -273,7 +273,7 @@ class ClickHouseModel(with_metaclass(ClickHouseModelMeta, InfiModel)):
|
||||||
:return: Boolean
|
:return: Boolean
|
||||||
"""
|
"""
|
||||||
if not cls.sync_enabled:
|
if not cls.sync_enabled:
|
||||||
logger.debug('django-clickhouse: need_sync returned False for class %s as sync is deisabled' % cls.__name__)
|
logger.debug('django-clickhouse: need_sync returned False for class %s as sync is disabled' % cls.__name__)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
last_sync_time = cls.get_storage().get_last_sync_time(cls.get_import_key())
|
last_sync_time = cls.get_storage().get_last_sync_time(cls.get_import_key())
|
||||||
|
@ -349,7 +349,6 @@ class ClickHouseMultiModel(ClickHouseModel):
|
||||||
|
|
||||||
with statsd.timer(statsd_key.format('steps.post_sync')):
|
with statsd.timer(statsd_key.format('steps.post_sync')):
|
||||||
storage.post_sync(import_key)
|
storage.post_sync(import_key)
|
||||||
storage.set_last_sync_time(import_key, datetime.datetime.now())
|
|
||||||
|
|
||||||
except RedisLockTimeoutError:
|
except RedisLockTimeoutError:
|
||||||
pass # skip this sync round if lock is acquired by another thread
|
pass # skip this sync round if lock is acquired by another thread
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
|
import datetime
|
||||||
import importlib
|
import importlib
|
||||||
|
|
||||||
from celery import shared_task
|
from celery import shared_task
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from infi.clickhouse_orm.utils import import_submodules
|
from infi.clickhouse_orm.utils import import_submodules
|
||||||
from statsd.defaults.django import statsd
|
|
||||||
|
|
||||||
from django_clickhouse.clickhouse_models import ClickHouseModel
|
from django_clickhouse.clickhouse_models import ClickHouseModel
|
||||||
from .configuration import config
|
from .configuration import config
|
||||||
|
@ -17,6 +17,7 @@ def sync_clickhouse_model(cls): # type: (ClickHouseModel) -> None
|
||||||
:param cls: ClickHouseModel subclass
|
:param cls: ClickHouseModel subclass
|
||||||
:return: None
|
:return: None
|
||||||
"""
|
"""
|
||||||
|
cls.get_storage().set_last_sync_time(cls.get_import_key(), datetime.datetime.now())
|
||||||
cls.sync_batch_from_storage()
|
cls.sync_batch_from_storage()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user