Esempio n. 1
0
    def get(self, request, item, page, *args, **kwargs):
        """获取规则类型、特征类型、打分卡类型 配置信息"""
        data = {'status': 1, 'message': 'success'}
        try:
            current_page = page
            page_size = 100
            obj = FeatureType
            if item == 'feature_type':
                obj = FeatureType.objects.values()
            elif item == 'feature_card_type':
                obj = FeatureCardType.objects.values()
            elif item == 'feature_rule_type':
                obj = FeatureRuleType.objects.values()
            count = obj.count()

            paginator = ExtPaginator(list(obj), page_size, count)
            object_list = paginator.page(current_page)
            page_num = paginator.num_pages
            page_range = paginator.page_range

            res_data = dict(total_count=count,
                            page_num=page_num,
                            current_page=current_page,
                            config_list=list(object_list),
                            page_range=page_range)

            data.update({"res_data": res_data})
        except Exception as e:
            logger.error(e.message)
            data = {'status': '0', 'message': e.message}

        return json_response(data)
Esempio n. 2
0
    def get(self, request, featurename, page, *args, **kwargs):
        """获取特征计算配置信息"""
        data = {'status': 1, 'message': 'success'}
        try:
            current_page = page
            page_size = 10
            if featurename == 'all':
                feature_config_obj = FeatureProcess.objects.values()
            else:
                feature_config_obj = FeatureProcess.objects.filter(
                    feature_name=featurename).values()
            feature_config_count = feature_config_obj.count()

            paginator = ExtPaginator(list(feature_config_obj), page_size,
                                     feature_config_count)
            object_list = paginator.page(current_page)
            page_num = paginator.num_pages
            page_range = paginator.page_range

            res_data = dict(total_count=feature_config_count,
                            page_num=page_num,
                            current_page=current_page,
                            config_list=list(object_list),
                            page_range=page_range)

            data.update({"res_data": res_data})
        except Exception as e:
            logger.error(e.message)
            data = {'status': '0', 'message': e.message}

        return json_response(data)
Esempio n. 3
0
    def get(self, request, featurename, page, *args, **kwargs):
        """获取分流特征基础配置信息"""
        data = {'status': 1, 'message': 'success'}
        try:
            current_page = page
            page_size = 500
            if featurename == 'all':
                feature_config_obj = FeatureShuntConf.objects.values()
            else:
                feature_config_obj = FeatureShuntConf.objects.filter(
                    feature_name=featurename).values()
            feature_config_count = feature_config_obj.count()

            paginator = ExtPaginator(list(feature_config_obj), page_size,
                                     feature_config_count)
            object_list = paginator.page(current_page)
            map(
                lambda x: [
                    x.update({
                        "created_on":
                        x["created_on"].strftime('%Y-%m-%d %H:%M:%S')
                        if x["created_on"] else ''
                    }),
                    x.update({
                        "updated_on":
                        x["updated_on"].strftime('%Y-%m-%d %H:%M:%S')
                        if x["updated_on"] else ''
                    }),
                    x.update({
                        "shunt_value":
                        x["shunt_value"] if x["shunt_value"] else ''
                    }),
                ], object_list)

            page_num = paginator.num_pages
            page_range = paginator.page_range

            res_data = dict(total_count=feature_config_count,
                            page_num=page_num,
                            current_page=current_page,
                            config_list=list(object_list),
                            page_range=page_range)

            data.update({"res_data": res_data})
        except Exception as e:
            logger.error(e.message)
            data = {'status': '0', 'message': e.message}

        return json_response(data)
Esempio n. 4
0
    def get(self, request, data_identity, page, *args, **kwargs):
        """获取数据源基础配置信息"""
        data = {'status': 1, 'message': 'success'}
        try:
            current_page = page
            page_size = 100
            if data_identity == 'all':
                data_identity_obj = DsInterfaceInfo.objects.values()
            else:
                data_identity_obj = DsInterfaceInfo.objects.filter(
                    data_identity=data_identity).values()
            data_identity_count = data_identity_obj.count()

            paginator = ExtPaginator(list(data_identity_obj), page_size,
                                     data_identity_count)
            object_list = paginator.page(current_page)
            map(
                lambda x: [
                    x.update({
                        "created_on":
                        x["created_on"].strftime('%Y-%m-%d %H:%M:%S')
                        if x["created_on"] else ''
                    }),
                    x.update({
                        "updated_on":
                        x["updated_on"].strftime('%Y-%m-%d %H:%M:%S')
                        if x["updated_on"] else ''
                    }),
                    # x.update({"must_data": eval(x["must_data"]) if x["must_data"] else ''}),
                ],
                object_list)

            page_num = paginator.num_pages
            page_range = paginator.page_range

            res_data = dict(total_count=data_identity_count,
                            page_num=page_num,
                            current_page=current_page,
                            config_list=list(object_list),
                            page_range=page_range)
            data.update({"res_data": res_data})
        except Exception as e:
            logger.error(e.message)
            data = {'status': '0', 'message': e.message}

        return json_response(data)