Esempio n. 1
0
def start_statistics_quiz_trends(self, cache_key, stat_type, m_city_code_list,
                                 province_code_list, city_code_list,
                                 gender_list, age_group_list, education_list,
                                 time_range):
    """
    公民科学素质学习答题趋势统计
    :param self:
    :param cache_key:
    :param stat_type:
    :param m_city_code_list:
    :param province_code_list:
    :param city_code_list:
    :param gender_list:
    :param age_group_list:
    :param education_list:
    :param time_range:
    :return:
    """

    logger.info('[START] REPORT_QUIZ_TRENDS(%s), cache_key=%s' %
                (self.request.id, cache_key))

    try:
        province_code_list = list(map(lambda x: int(x), province_code_list))
        city_code_list = list(map(lambda x: int(x), city_code_list))
        gender_list = list(map(lambda x: int(x), gender_list))
        age_group_list = list(map(lambda x: int(x), age_group_list))
        education_list = list(map(lambda x: int(x), education_list))

        save_cache_condition('start_statistics_quiz_trends',
                             cache_key=cache_key,
                             stat_type=stat_type,
                             m_city_code_list=m_city_code_list,
                             province_code_list=province_code_list,
                             city_code_list=city_code_list,
                             gender_list=gender_list,
                             age_group_list=age_group_list,
                             education_list=education_list,
                             time_range=time_range)
        do_statistics_quiz_trends(cache_key, stat_type, m_city_code_list,
                                  province_code_list, city_code_list,
                                  gender_list, age_group_list, education_list,
                                  time_range)
    except Exception:
        logger.warning(
            '[ERROR] REPORT_QUIZ_TRENDS(%s): cache_key=%s, locals=%s, \n %s' %
            (self.request.id, cache_key, str(
                locals()), traceback.format_exc()))
        early_warning(self.request.id, 'start_statistics_quiz_trends',
                      cache_key, locals(), traceback.format_exc())
    logger.info('[ END ] REPORT_QUIZ_TRENDS(%s)' % self.request.id)
Esempio n. 2
0
def start_statistics_subject_parameter_radar(self, cache_key,
                                             root_dimension_code,
                                             m_city_code_list,
                                             province_code_list,
                                             city_code_list, gender_list,
                                             age_group_list, education_list):
    """

    :param self:
    :param cache_key:
    :param root_dimension_code:
    :param m_city_code_list:
    :param province_code_list:
    :param city_code_list:
    :param gender_list:
    :param age_group_list:
    :param education_list:
    :return:
    """
    logger.info('[START] SUBJECT_PARAMETER_RADAR(%s), cache_key=%s' %
                (self.request.id, cache_key))

    try:
        save_cache_condition('start_statistics_subject_parameter_radar',
                             cache_key=cache_key,
                             root_dimension_code=root_dimension_code,
                             m_city_code_list=m_city_code_list,
                             province_code_list=province_code_list,
                             city_code_list=city_code_list,
                             gender_list=gender_list,
                             age_group_list=age_group_list,
                             education_list=education_list)
        do_statistics_subject_radar(cache_key=cache_key,
                                    root_dimension_code=root_dimension_code,
                                    m_city_code_list=m_city_code_list,
                                    province_code_list=province_code_list,
                                    city_code_list=city_code_list,
                                    gender_list=gender_list,
                                    age_group_list=age_group_list,
                                    education_list=education_list)
    except Exception:
        logger.warning(
            '[ERROR] SUBJECT_PARAMETER_RADAR(%s): cache_key=%s, locals=%s\n %s'
            % (self.request.id, cache_key, str(
                locals()), traceback.format_exc()))
        early_warning(self.request.id,
                      'start_statistics_subject_parameter_radar', cache_key,
                      locals(), traceback.format_exc())
    logger.info('[ END ] SUBJECT_PARAMETER_RADAR(%s)' % self.request.id)
Esempio n. 3
0
def start_statistics_member_active(self, cache_key, m_city_code_list,
                                   province_code_list, city_code_list,
                                   gender_list, age_group_list,
                                   education_list):
    """
    公民科学素质学习答题活跃度
    :param self:
    :param cache_key:
    :param m_city_code_list:
    :param province_code_list:
    :param city_code_list:
    :param gender_list:
    :param age_group_list:
    :param education_list:
    :return:
    """

    logger.info('[START] REPORT_MEMBER_ACTIVE(%s), cache_key=%s' %
                (self.request.id, cache_key))

    try:
        save_cache_condition('start_statistics_member_active',
                             cache_key=cache_key,
                             m_city_code_list=m_city_code_list,
                             province_code_list=province_code_list,
                             city_code_list=city_code_list,
                             gender_list=gender_list,
                             age_group_list=age_group_list,
                             education_list=education_list)
        do_statistics_member_active(cache_key=cache_key,
                                    m_city_code_list=m_city_code_list,
                                    province_code_list=province_code_list,
                                    city_code_list=city_code_list,
                                    gender_list=gender_list,
                                    age_group_list=age_group_list,
                                    education_list=education_list)
    except Exception:
        logger.warning(
            '[ERROR] REPORT_MEMBER_ACTIVE(%s): cache_key=%s, locals=%s, \n %s'
            % (self.request.id, cache_key, str(
                locals()), traceback.format_exc()))
        early_warning(self.request.id, 'start_statistics_member_active',
                      cache_key, locals(), traceback.format_exc())
    logger.info('[ END ] REPORT_MEMBER_ACTIVE(%s)' % self.request.id)
Esempio n. 4
0
def start_statistics_member_accuracy(self, cache_key, city_code_list, choice_time):
    """

    :param self:
    :param cache_key:
    :param city_code_list:
    :param choice_time
    :return:
    """
    logger.info('[START] MEMBER_ACCURACY_STATISTICS(%s), cache_key=%s' % (self.request.id, cache_key))

    try:
        save_cache_condition('start_statistics_member_accuracy', cache_key=cache_key, city_code_list=city_code_list,
                             choice_time="")
        do_statistics_accuracy(cache_key, city_code_list, choice_time)
    except Exception:
        logger.warning(
            '[ERROR] MEMBER_ACCURACY_STATISTICS(%s): locals=%s\n %s' % (
                self.request.id, str(locals()), traceback.format_exc()))

    logger.info('[ END ] MEMBER_ACCURACY_STATISTICS(%s)' % self.request.id)
Esempio n. 5
0
def start_statistics_member_quantity(self, cache_key, city_code_list, choice_time):
    """启动任务

    :param self:
    :param cache_key:
    :param city_code_list:
    :param choice_time
    :return:
    """
    logger.info('[START] MEMBER_QUANTITY_STATISTICS(%s), cache_key=%s' % (self.request.id, cache_key))

    try:
        save_cache_condition('start_statistics_member_quantity', cache_key=cache_key,
                             city_code_list=city_code_list, choice_time="")
        do_statistics_member_quantity(cache_key, city_code_list, choice_time)
    except Exception:
        logger.warning(
            '[ERROR] MEMBER_QUANTITY_STATISTICS(%s): cache_key=%s, city_code_list=%s\n %s' % (
                self.request.id, cache_key, str(city_code_list), traceback.format_exc()))
        early_warning(self.request.id, "MEMBER_QUANTITY_STATISTICS", cache_key, city_code_list, traceback.format_exc())
    logger.info('[ END ] MEMBER_QUANTITY_STATISTICS(%s)' % self.request.id)
Esempio n. 6
0
def start_statistics_member_top_n(self,
                                  cache_key=None,
                                  m_city_code_list=None,
                                  stat_type=None,
                                  top_n=None,
                                  time_range=None):
    """
    每日参与TOP 5

    :param self:
    :param cache_key:
    :param m_city_code_list:
    :param stat_type:
    :param top_n:
    :param time_range:
    :return:
    """
    logger.info('[START] REPORT_MEMBER_TOP_N(%s), cache_key=%s' %
                (self.request.id, cache_key))

    try:
        save_cache_condition('start_statistics_member_top_n',
                             cache_key=cache_key,
                             m_city_code_list=m_city_code_list,
                             stat_type=stat_type,
                             top_n=top_n,
                             time_range=time_range)
        do_statistics_member_top_n(cache_key=cache_key,
                                   m_city_code_list=m_city_code_list,
                                   stat_type=stat_type,
                                   top_n=top_n,
                                   time_range=time_range)
    except Exception:
        logger.warning(
            '[ERROR] REPORT_MEMBER_TOP_N(%s): cache_key=%s, locals=%s, \n %s' %
            (self.request.id, cache_key, str(
                locals()), traceback.format_exc()))
        early_warning(self.request.id, 'start_statistics_member_top_n',
                      cache_key, locals(), traceback.format_exc())
    logger.info('[ END ] REPORT_MEMBER_TOP_N(%s)' % self.request.id)
def start_statistics_subject_quantity(self, cache_key, m_province_code_list,
                                      m_city_code_list, s_province_code_list,
                                      s_city_code_list, s_gender_list,
                                      s_age_group_list, s_education_list):
    """

    :param self:
    :param cache_key:
    :param m_province_code_list:
    :param m_city_code_list:
    :param s_province_code_list:
    :param s_city_code_list:
    :param s_gender_list:
    :param s_age_group_list:
    :param s_education_list:
    :return:
    """
    logger.info('[START] MEMBER_QUANTITY_STATISTICS(%s), cache_key=%s' %
                (self.request.id, cache_key))

    try:
        save_cache_condition('start_statistics_subject_quantity',
                             cache_key=cache_key,
                             m_province_code_list=m_province_code_list,
                             m_city_code_list=m_city_code_list,
                             s_province_code_list=s_province_code_list,
                             s_city_code_list=s_city_code_list,
                             s_gender_list=s_gender_list,
                             s_age_group_list=s_age_group_list,
                             s_education_list=s_education_list)
        do_statistics_subject_parameter(
            cache_key=cache_key,
            m_province_code_list=m_province_code_list,
            m_city_code_list=m_city_code_list,
            s_province_code_list=s_province_code_list,
            s_city_code_list=s_city_code_list,
            s_gender_list=s_gender_list,
            s_age_group_list=s_age_group_list,
            s_education_list=s_education_list)
    except Exception:
        logger.warning(
            '[ERROR] MEMBER_QUANTITY_STATISTICS(%s): params=%s\n %s' %
            (self.request.id,
             str(
                 dict(cache_key=cache_key,
                      m_province_code_list=m_province_code_list,
                      m_city_code_list=m_city_code_list,
                      s_province_code_list=s_province_code_list,
                      s_city_code_list=s_city_code_list,
                      s_gender_list=s_gender_list,
                      s_age_group_list=s_age_group_list,
                      s_education_list=s_education_list)),
             traceback.format_exc()))
        early_warning(
            self.request.id, 'start_statistics_subject_quantity', cache_key,
            str(
                dict(cache_key=cache_key,
                     m_province_code_list=m_province_code_list,
                     m_city_code_list=m_city_code_list,
                     s_province_code_list=s_province_code_list,
                     s_city_code_list=s_city_code_list,
                     s_gender_list=s_gender_list,
                     s_age_group_list=s_age_group_list,
                     s_education_list=s_education_list)),
            traceback.format_exc())

    logger.info('[ END ] MEMBER_QUANTITY_STATISTICS(%s)' % self.request.id)
Esempio n. 8
0
def start_statistics_learning_situation(self,
                                        cache_key,
                                        chart_type=None,
                                        m_city_code_list=None,
                                        gender_list=None,
                                        province_code_list=None,
                                        city_code_list=None,
                                        age_group_list=None,
                                        education_list=None,
                                        dimension=None,
                                        time_range=None,
                                        dimension_code=None):
    """
    学习效果任务LEARNING_SITUATION_STATISTICS
    :param self:
    :param cache_key:
    :param chart_type:
    :param m_city_code_list:
    :param gender_list:
    :param province_code_list:
    :param city_code_list:
    :param age_group_list:
    :param education_list:
    :param dimension:
    :param time_range:
    :param dimension_code:
    :return:
    """

    logger.info('[START] LEARNING_SITUATION_STATISTICS(%s), cache_key=%s' %
                (self.request.id, cache_key))
    try:
        save_cache_condition('start_statistics_learning_situation',
                             cache_key=cache_key,
                             chart_type=chart_type,
                             m_city_code_list=m_city_code_list,
                             gender_list=gender_list,
                             province_code_list=province_code_list,
                             city_code_list=city_code_list,
                             age_group_list=age_group_list,
                             education_list=education_list,
                             dimension=dimension,
                             time_range=time_range,
                             dimension_code=dimension_code)
        do_statistics_learning_situation(cache_key=cache_key,
                                         chart_type=chart_type,
                                         m_city_code_list=m_city_code_list,
                                         gender_list=gender_list,
                                         province_code_list=province_code_list,
                                         city_code_list=city_code_list,
                                         age_group_list=age_group_list,
                                         education_list=education_list,
                                         dimension=dimension,
                                         time_range=time_range,
                                         dimension_code=dimension_code)
    except Exception:
        logger.error('[ERROR] locals_variable: %s \n %s' %
                     (str(locals()), traceback.format_exc()))
        content = 'host=%s,[ERROR] LEARNING_SITUATION_STATISTICS(%s), time=%s,locals_variable: %s \n %s' % (
            settings.SERVER_HOST, self.request.id,
            datetime2str(datetime.datetime.now()), str(
                locals()), traceback.format_exc())

        send_instant_mail(
            mail_to=['*****@*****.**', '*****@*****.**'],
            subject='学习效果报表任务失败',
            content=content)
    logger.info('[ END ] LEARNING_SITUATION_STATISTICS(%s)' % self.request.id)