Example #1
0
def icds_state_aggregation_task(self, state_id, date, func):
    if six.PY2 and isinstance(date, bytes):
        date = date.decode('utf-8')

    db_alias = get_icds_ucr_db_alias()
    if not db_alias:
        return

    celery_task_logger.info("Starting icds reports {} {} {}".format(state_id, date, func.__name__))

    try:
        func(state_id, date)
    except Error as exc:
        notify_exception(
            None, message="Error occurred during ICDS aggregation",
            details={'func': func.__name__, 'date': date, 'state_id': state_id, 'error': exc}
        )
        _dashboard_team_soft_assert(
            False,
            "{} aggregation failed on {} for {} on {}. This task will be retried in 15 minutes".format(
                func.__name__, settings.SERVER_ENVIRONMENT, state_id, date
            )
        )
        self.retry(exc=exc)

    celery_task_logger.info("Ended icds reports {} {} {}".format(state_id, date, func.__name__))
Example #2
0
 def test_string_transform(self):
     transform = TransformFactory.get_transform({
         "type": "custom",
         "custom_type": "days_elapsed_from_date"
     })
     date = (datetime.utcnow() - timedelta(days=5)).strftime('%Y-%m-%d')
     if six.PY2:
         date = date.decode('utf-8')
     self.assertEqual(transform.transform(date), 5)
Example #3
0
 def test_string_transform(self):
     transform = TransformFactory.get_transform({
         "type":
         "custom",
         "custom_type":
         "days_elapsed_from_date"
     })
     date = (datetime.utcnow() - timedelta(days=5)).strftime('%Y-%m-%d')
     if six.PY2:
         date = date.decode('utf-8')
     self.assertEqual(transform.transform(date), 5)
Example #4
0
def icds_state_aggregation_task(self, state_id, date, func_name):
    func = {
        '_aggregate_gm_forms': _aggregate_gm_forms,
        '_aggregate_df_forms': _aggregate_df_forms,
        '_aggregate_cf_forms': _aggregate_cf_forms,
        '_aggregate_ccs_cf_forms': _aggregate_ccs_cf_forms,
        '_aggregate_child_health_thr_forms': _aggregate_child_health_thr_forms,
        '_aggregate_ccs_record_thr_forms': _aggregate_ccs_record_thr_forms,
        '_aggregate_child_health_pnc_forms': _aggregate_child_health_pnc_forms,
        '_aggregate_ccs_record_pnc_forms': _aggregate_ccs_record_pnc_forms,
        '_aggregate_delivery_forms': _aggregate_delivery_forms,
        '_aggregate_bp_forms': _aggregate_bp_forms,
        '_aggregate_awc_infra_forms': _aggregate_awc_infra_forms,
        '_child_health_monthly_table': _child_health_monthly_table,
        '_agg_ls_awc_mgt_form': _agg_ls_awc_mgt_form,
        '_agg_ls_vhnd_form': _agg_ls_vhnd_form,
        '_agg_beneficiary_form': _agg_beneficiary_form,
    }[func_name]

    if six.PY2 and isinstance(date, bytes):
        date = date.decode('utf-8')

    db_alias = get_icds_ucr_db_alias()
    if not db_alias:
        return

    celery_task_logger.info("Starting icds reports {} {} {}".format(
        state_id, date, func.__name__))

    try:
        func(state_id, date)
    except Error as exc:
        notify_exception(None,
                         message="Error occurred during ICDS aggregation",
                         details={
                             'func': func.__name__,
                             'date': date,
                             'state_id': state_id,
                             'error': exc
                         })
        _dashboard_team_soft_assert(
            False,
            "{} aggregation failed on {} for {} on {}. This task will be retried in 15 minutes"
            .format(func.__name__, settings.SERVER_ENVIRONMENT, state_id,
                    date))
        self.retry(exc=exc)

    celery_task_logger.info("Ended icds reports {} {} {}".format(
        state_id, date, func.__name__))
Example #5
0
def icds_aggregation_task(self, date, func_name):
    func = {
        '_agg_ls_table': _agg_ls_table,
        '_update_months_table': _update_months_table,
        '_daily_attendance_table': _daily_attendance_table,
        '_agg_child_health_table': _agg_child_health_table,
        '_ccs_record_monthly_table': _ccs_record_monthly_table,
        '_agg_ccs_record_table': _agg_ccs_record_table,
        '_agg_awc_table': _agg_awc_table,
        '_agg_awc_table_weekly': _agg_awc_table_weekly,
        'aggregate_awc_daily': aggregate_awc_daily,
    }[func_name]

    if six.PY2 and isinstance(date, bytes):
        date = date.decode('utf-8')

    db_alias = get_icds_ucr_db_alias()
    if not db_alias:
        return

    celery_task_logger.info("Starting icds reports {} {}".format(
        date, func.__name__))
    try:
        func(date)
    except Error as exc:
        notify_exception(None,
                         message="Error occurred during ICDS aggregation",
                         details={
                             'func': func.__name__,
                             'date': date,
                             'error': exc
                         })
        _dashboard_team_soft_assert(
            False,
            "{} aggregation failed on {} for {}. This task will be retried in 15 minutes"
            .format(func.__name__, settings.SERVER_ENVIRONMENT, date))
        self.retry(exc=exc)

    celery_task_logger.info("Ended icds reports {} {}".format(
        date, func.__name__))
	def getDatetime(self, my_date):
		date = my_date.to_ical()
		dtutcdate = pytz.utc.localize(datetime.strptime(date.decode(), self.format))
		dtdate = dtutcdate.astimezone(self.paris)

		return dtdate