def test_make_buckets_from_timedeltas(): buckets = [1, 10, 60, 10 * 60, 60 * 60, 12 * 60 * 60, 24 * 60 * 60] eq(make_buckets_from_timedeltas( timedelta(seconds=1), timedelta(seconds=10), timedelta(minutes=1), timedelta(minutes=10), timedelta(hours=1), timedelta(hours=12), timedelta(hours=24), ), buckets) eq(DAY_SCALE_TIME_BUCKETS, buckets)
def test_make_buckets_from_timedeltas(): buckets = [1, 10, 60, 10 * 60, 60 * 60, 12 * 60 * 60, 24 * 60 * 60] eq( make_buckets_from_timedeltas( timedelta(seconds=1), timedelta(seconds=10), timedelta(minutes=1), timedelta(minutes=10), timedelta(hours=1), timedelta(hours=12), timedelta(hours=24), ), buckets) eq(DAY_SCALE_TIME_BUCKETS, buckets)
) from corehq.util.datadog.gauges import ( datadog_bucket_timer, datadog_counter, datadog_gauge_task, ) from corehq.util.datadog.utils import make_buckets_from_timedeltas from corehq.util.soft_assert import soft_assert from dimagi.utils.couch import get_redis_lock from dimagi.utils.couch.undo import DELETED_SUFFIX _check_repeaters_buckets = make_buckets_from_timedeltas( timedelta(seconds=10), timedelta(minutes=1), timedelta(minutes=5), timedelta(hours=1), timedelta(hours=5), timedelta(hours=10), ) _soft_assert = soft_assert(to='@'.join(('nhooper', 'dimagi.com'))) logging = get_task_logger(__name__) @periodic_task( run_every=CHECK_REPEATERS_INTERVAL, queue=settings.CELERY_PERIODIC_QUEUE, ) def check_repeaters(): start = datetime.utcnow() six_hours_sec = 6 * 60 * 60 six_hours_later = start + timedelta(seconds=six_hours_sec)
RECORD_PENDING_STATE, ) from corehq.motech.repeaters.dbaccessors import ( get_overdue_repeat_record_count, iterate_repeat_records, ) from corehq.privileges import DATA_FORWARDING, ZAPIER_INTEGRATION from corehq.util.datadog.gauges import ( datadog_bucket_timer, ) from corehq.util.datadog.utils import make_buckets_from_timedeltas from corehq.util.soft_assert import soft_assert _check_repeaters_buckets = make_buckets_from_timedeltas( timedelta(seconds=10), timedelta(minutes=1), timedelta(minutes=5), timedelta(hours=1), timedelta(hours=5), timedelta(hours=10), ) _soft_assert = soft_assert(to='@'.join(('nhooper', 'dimagi.com'))) logging = get_task_logger(__name__) @periodic_task( run_every=crontab(day_of_month=27), queue=settings.CELERY_PERIODIC_QUEUE, ) def clean_logs(): """ Drop MOTECH logs older than 90 days.