Esempio n. 1
0
class FeedDataDriver(object):
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'feeds', 'users', 'members', 'self_members',
            'all_data_self_members', 'manual_service_members',
            'all_data_manual_service_members', 'user_access_log'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_lively_feed_count(self):
        ret = self.origin_data.get('feeds').filter(
            deleted=False,
            feed_expire_time__gt=datetime.datetime.now(),
            feed_type=1)
        return ret.count()

    def get_new_feed(self):
        return self.origin_data.get('feeds').filter(
            add_time__gte=get_today() - datetime.timedelta(days=1),
            add_time__lt=datetime.datetime.now()).count()

    def get_lively_feed_user_count(self):
        user_log = self.origin_data.get('user_access_log')

        user_list = user_log.filter(
            access_url='/special_feed/page/', ).distinct('user_name')

        return len(user_list)

    def get_lively_feed_member_count(self):

        self_member_list = self.origin_data.get('all_data_self_members')
        manual_service_member_list = self.origin_data.get(
            'all_data_manual_service_members')

        member_list = []
        member_list.extend(
            self_member_list.values_list('user__username', flat=True))
        member_list.extend(
            manual_service_member_list.values_list('user__username',
                                                   flat=True))

        user_log = self.origin_data.get('user_access_log')

        user_list = user_log.filter(
            access_url__contains='/special_feed/feed_list/', ).distinct(
                'user_name')

        return len([val for val in user_list if val in member_list])
Esempio n. 2
0
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'task_system',
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
Esempio n. 3
0
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'pub_feeds', 'user_access_log', 'resumes', 'down_resumes',
            'send_cards', 'fav_resumes', 'all_data_user_mark_logs'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
Esempio n. 4
0
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'users', 'weixin_users', 'weixin_msgs', 'all_data_self_members',
            'all_data_manual_service_members', 'user_access_log'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
Esempio n. 5
0
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'users',
            'all_data_users',
            'first_data_users',
            'experience_users',
            'all_data_experience_users',
            'members',
            'all_data_members',
            'self_members',
            'all_data_self_members',
            'manual_service_members',
            'all_data_manual_service_members',
            'user_access_log'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = ['pub_feeds', 'statistic', 'feed_result', 'resumes', 'down_resumes', 'send_cards', 'fav_resumes', 'all_data_user_mark_logs', 'first_data_staffs']
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
Esempio n. 7
0
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'tasks',
            'all_data_tasks',
            'upload_resumes',
            'all_data_upload_resumes',
            'task_coin_records',
            'all_data_task_coin_records',
            'do_tasks',
            'all_data_do_tasks'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = ['pub_feeds', 'user_access_log', 'resumes', 'down_resumes', 'send_cards', 'fav_resumes', 'all_data_user_mark_logs', 'first_data_staff', 'statistic']
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
        self.staff_list = self.origin_data.get('first_data_staff').values_list('username', flat=True)
Esempio n. 9
0
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'task_system',
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
class ResumeDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = ['pub_feeds', 'user_access_log', 'resumes', 'down_resumes', 'send_cards', 'fav_resumes', 'all_data_user_mark_logs', 'first_data_staff', 'statistic']
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
        self.staff_list = self.origin_data.get('first_data_staff').values_list('username', flat=True)

    def get_new_recommend_count(self):
        return sum(len(data['resumes']) for data in self.origin_data.get('pub_feeds').as_pymongo() if data['email'] not in self.staff_list)

    def get_new_view_count(self):

        user_log = self.origin_data.get('user_access_log')
        user_list = user_log.filter(
            access_url__contains='/resumes/display/',
        )
        # 去除管理员
        ret = [u for u in user_list if u.user_name not in self.staff_list]

        return len(ret)

    def get_new_view_proportion(self):
        return get_proportion(self.get_new_view_count(), self.get_new_recommend_count())

    def get_new_fav_count(self):
        return self.origin_data.get('fav_resumes').exclude(
            user__is_staff=True
        ).count()

    def get_new_down_count(self):
        return self.origin_data.get('resumes').exclude(
            user__is_staff=True
        ).count()

    def get_new_down_proportion(self):
        return get_proportion(self.get_new_down_count(), self.get_new_view_count())

    def get_new_send_card_count(self):
        return self.origin_data.get('send_cards').exclude(
            send_user__is_staff=True
        ).count()

    def get_new_interview_count(self):

        condition = [
            'invite_interview',
            'join_interview',
            'break_invite',
            'send_offer',
            'reject_offer'
        ]
        mark_ids = self.origin_data.get('down_resumes').select_related('ResumeMarkSetting').filter(
            current_mark__code_name__in=condition
        ).values_list('buy_record', flat=True)

        all_user_mark_logs = self.origin_data.get('all_data_user_mark_logs').select_related('ResumeMarkSetting').filter(
            mark__code_name__in=condition,
            mark_time__lte=get_today() - datetime.timedelta(days=1)
        ).exclude(
            user__is_staff=True
        ).values_list('resume_mark', flat=True)

        return len([val for val in mark_ids if val not in all_user_mark_logs])

    def get_new_entered_count(self):
        ret = self.origin_data.get('down_resumes').select_related('ResumeMarkSetting').filter(
            current_mark__code_name__in=[
                'entry'
            ]
        ).exclude(
            buy_record__user__is_staff=True
        )
        return ret.count()
Esempio n. 11
0
class CoreDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'users',
            'members',
            'self_members',
            'all_data_self_members',
            'manual_service_members',
            'all_data_manual_service_members',
            'user_access_log'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
        self.get_member_list()

    def get_member_list(self):

        self_member_list = self.origin_data.get('all_data_self_members')
        manual_service_member_list = self.origin_data.get('all_data_manual_service_members')

        self.member_list = []
        self.member_list.extend(self_member_list.values_list('user__username', flat=True))
        self.member_list.extend(manual_service_member_list.values_list('user__username', flat=True))
        self.member_list = set(self.member_list)

    def get_new_register_user_count(self):
        return self.origin_data.get('users').count()

    def get_active_user_count(self):
        ret = self.origin_data.get('users')
        return ret.filter(
            user__is_active=True
        ).count()

    def get_member_count(self):
        ret = self.origin_data.get('members')
        return len(ret)

    def get_lively_user_count(self):
        ret = self.origin_data.get('user_access_log')
        return len(ret.values_list('user_name').distinct('user_name'))

    def get_week_lively_user_count(self):
        return self.get_lively_user_count()

    def get_month_lively_user_count(self):
        return self.get_lively_user_count()

    def get_lively_member_count(self):

        user_list = self.origin_data.get('user_access_log').values_list('user_name').distinct('user_name')
        return len([val for val in user_list if val in self.member_list])

    def get_week_lively_member_count(self):
        return self.get_lively_member_count()

    def get_month_lively_member_count(self):
        return self.get_lively_member_count()

    def get_repeat_visit_count(self):
        result = {}
        user_list = list(self.origin_data.get('user_access_log').values_list('user_name'))
        for key in user_list:

            if user_list.count(key) > 1:
                result[key] = 2
        return len(result)

    def get_week_repeat_visit_user_count(self):
        return self.get_repeat_visit_count()

    def get_week_repeat_visit_member_count(self):

        result = {}
        user_list = list(self.origin_data.get('user_access_log').values_list('user_name'))

        user_list = [val for val in user_list if val in self.member_list]

        for key in user_list:

            if user_list.count(key) > 1:
                result[key] = 2
        return len(result)

    def get_month_repeat_visit_user_count(self):
        return self.get_repeat_visit_count()

    def get_month_repeat_visit_member_count(self):

        result = {}
        user_list = list(self.origin_data.get('user_access_log').values_list('user_name'))

        user_list = [val for val in user_list if val in self.member_list]
        for key in user_list:

            if user_list.count(key) > 1:
                result[key] = 2
        return len(result)
Esempio n. 12
0
class FeedDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'feeds',
            'users',
            'members',
            'self_members',
            'all_data_self_members',
            'manual_service_members',
            'all_data_manual_service_members',
            'user_access_log'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_lively_feed_count(self):
        ret = self.origin_data.get('feeds').filter(
            deleted=False,
            feed_expire_time__gt=datetime.datetime.now(),
            feed_type=1
        )
        return ret.count()

    def get_new_feed(self):
        return self.origin_data.get('feeds').filter(
            add_time__gte=get_today() - datetime.timedelta(days=1),
            add_time__lt=datetime.datetime.now()
        ).count()

    def get_lively_feed_user_count(self):
        user_log = self.origin_data.get('user_access_log')

        user_list = user_log.filter(
            access_url='/special_feed/page/',
        ).distinct('user_name')

        return len(user_list)

    def get_lively_feed_member_count(self):

        self_member_list = self.origin_data.get('all_data_self_members')
        manual_service_member_list = self.origin_data.get('all_data_manual_service_members')

        member_list = []
        member_list.extend(self_member_list.values_list('user__username', flat=True))
        member_list.extend(manual_service_member_list.values_list('user__username', flat=True))

        user_log = self.origin_data.get('user_access_log')

        user_list = user_log.filter(
            access_url__contains='/special_feed/feed_list/',
        ).distinct('user_name')

        return len([val for val in user_list if val in member_list])
Esempio n. 13
0
class CoreDataDriver(object):
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'users', 'members', 'self_members', 'all_data_self_members',
            'manual_service_members', 'all_data_manual_service_members',
            'user_access_log'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
        self.get_member_list()

    def get_member_list(self):

        self_member_list = self.origin_data.get('all_data_self_members')
        manual_service_member_list = self.origin_data.get(
            'all_data_manual_service_members')

        self.member_list = []
        self.member_list.extend(
            self_member_list.values_list('user__username', flat=True))
        self.member_list.extend(
            manual_service_member_list.values_list('user__username',
                                                   flat=True))
        self.member_list = set(self.member_list)

    def get_new_register_user_count(self):
        return self.origin_data.get('users').count()

    def get_active_user_count(self):
        ret = self.origin_data.get('users')
        return ret.filter(user__is_active=True).count()

    def get_member_count(self):
        ret = self.origin_data.get('members')
        return len(ret)

    def get_lively_user_count(self):
        ret = self.origin_data.get('user_access_log')
        return len(ret.values_list('user_name').distinct('user_name'))

    def get_week_lively_user_count(self):
        return self.get_lively_user_count()

    def get_month_lively_user_count(self):
        return self.get_lively_user_count()

    def get_lively_member_count(self):

        user_list = self.origin_data.get('user_access_log').values_list(
            'user_name').distinct('user_name')
        return len([val for val in user_list if val in self.member_list])

    def get_week_lively_member_count(self):
        return self.get_lively_member_count()

    def get_month_lively_member_count(self):
        return self.get_lively_member_count()

    def get_repeat_visit_count(self):
        result = {}
        user_list = list(
            self.origin_data.get('user_access_log').values_list('user_name'))
        for key in user_list:

            if user_list.count(key) > 1:
                result[key] = 2
        return len(result)

    def get_week_repeat_visit_user_count(self):
        return self.get_repeat_visit_count()

    def get_week_repeat_visit_member_count(self):

        result = {}
        user_list = list(
            self.origin_data.get('user_access_log').values_list('user_name'))

        user_list = [val for val in user_list if val in self.member_list]

        for key in user_list:

            if user_list.count(key) > 1:
                result[key] = 2
        return len(result)

    def get_month_repeat_visit_user_count(self):
        return self.get_repeat_visit_count()

    def get_month_repeat_visit_member_count(self):

        result = {}
        user_list = list(
            self.origin_data.get('user_access_log').values_list('user_name'))

        user_list = [val for val in user_list if val in self.member_list]
        for key in user_list:

            if user_list.count(key) > 1:
                result[key] = 2
        return len(result)
Esempio n. 14
0
class TaskDailyDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'task_system',
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_task_A1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A1'
            ).count()

    def get_task_A2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A2'
            ).count()

    def get_task_A3_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A3'
            ).count()

    def get_task_A4_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A4'
            ).count()

    def get_task_A5_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A5'
            ).count()

    def get_task_A6_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A6'
            ).count()

    def get_task_A6_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A6_R1'
            ).count()

    def get_task_A6_R2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A6_R2'
            ).count()

    def get_task_A6_L1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A6_L1'
            ).count()

    def get_task_A7_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A7'
            ).count()

    def get_task_A7_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A7_R1'
            ).count()

    def get_task_A7_R2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A7_R2'
            ).count()

    def get_task_A7_R3_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A7_R3'
            ).count()

    def get_task_A8_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A8'
            ).count()

    def get_task_A8_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A8_R1'
            ).count()

    def get_task_A8_R2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A8_R2'
            ).count()

    def get_task_A8_R3_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A8_R3'
            ).count()

    def get_task_A9_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A9'
            ).count()

    def get_task_A9_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A9_R1'
            ).count()

    def get_task_A9_R2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A9_R2'
            ).count()

    def get_task_A9_R3_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A9_R3'
            ).count()

    def get_task_A10_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A10'
            ).count()

    def get_task_A10_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A10_R1'
            ).count()

    def get_task_A11_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A11'
            ).count()

    def get_task_A12_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A12'
            ).count()

    def get_task_A13_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A13'
            ).count()

    def get_task_A14_L1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A14_L1'
            ).count()

    def get_task_A15_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A15'
            ).count()

    def get_task_A15_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A15_R1'
            ).count()

    def get_task_A15_R2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A15_R2'
            ).count()

    def get_task_A16_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A16'
            ).count()

    def get_task_A17_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A17'
            ).count()

    def get_task_A18_R1_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A18_R1'
            ).count()

    def get_task_A18_R2_count(self):
        return self.origin_data.get('task_system').filter(
                task__task_id='A18_R2'
            ).count()
Esempio n. 15
0
class TaskDailyDataDriver(object):
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'task_system',
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_task_A1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A1').count()

    def get_task_A2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A2').count()

    def get_task_A3_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A3').count()

    def get_task_A4_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A4').count()

    def get_task_A5_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A5').count()

    def get_task_A6_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A6').count()

    def get_task_A6_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A6_R1').count()

    def get_task_A6_R2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A6_R2').count()

    def get_task_A6_L1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A6_L1').count()

    def get_task_A7_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A7').count()

    def get_task_A7_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A7_R1').count()

    def get_task_A7_R2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A7_R2').count()

    def get_task_A7_R3_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A7_R3').count()

    def get_task_A8_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A8').count()

    def get_task_A8_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A8_R1').count()

    def get_task_A8_R2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A8_R2').count()

    def get_task_A8_R3_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A8_R3').count()

    def get_task_A9_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A9').count()

    def get_task_A9_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A9_R1').count()

    def get_task_A9_R2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A9_R2').count()

    def get_task_A9_R3_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A9_R3').count()

    def get_task_A10_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A10').count()

    def get_task_A10_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A10_R1').count()

    def get_task_A11_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A11').count()

    def get_task_A12_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A12').count()

    def get_task_A13_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A13').count()

    def get_task_A14_L1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A14_L1').count()

    def get_task_A15_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A15').count()

    def get_task_A15_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A15_R1').count()

    def get_task_A15_R2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A15_R2').count()

    def get_task_A16_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A16').count()

    def get_task_A17_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A17').count()

    def get_task_A18_R1_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A18_R1').count()

    def get_task_A18_R2_count(self):
        return self.origin_data.get('task_system').filter(
            task__task_id='A18_R2').count()
Esempio n. 16
0
class WeixinDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'users',
            'weixin_users',
            'weixin_msgs',
            'all_data_self_members',
            'all_data_manual_service_members',
            'user_access_log'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_new_bind_weixin_user_count(self):
        return self.origin_data.get('weixin_users').filter(
            user__date_joined__lte=get_today() - datetime.timedelta(days=1)
        ).count()

    def get_new_reg_weixin_user_count(self):
        return self.origin_data.get('weixin_users').filter(
            user__date_joined__gte=get_today() - datetime.timedelta(days=1)
        ).count()

    def get_all_new_bind_weixin_user_count(self):
        return self.origin_data.get('weixin_users').count()

    def get_lively_member_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger',
        ).distinct('user_name')

        self_member_list = self.origin_data.get('all_data_self_members')
        manual_service_member_list = self.origin_data.get('all_data_manual_service_members')
        member_list = []
        member_list.extend(self_member_list.values_list('user__username', flat=True))
        member_list.extend(manual_service_member_list.values_list('user__username', flat=True))
        member_list = set(member_list)

        return len([val for val in user_log_list if val in member_list])

    def get_lively_user_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger',
        ).distinct('user_name')
        return len(user_log_list)

    def get_send_msg_count(self):
        return self.origin_data.get('weixin_msgs').count()

    def get_click_msg_count(self):

        user_access_urls = self.origin_data.get('user_access_log').filter(
            access_url__contains='/feed_list/'
        ).values_list('access_url')
        user_access_feed_ids = [re.findall(r'/feed_list/(\w*)', url)[0] for url in user_access_urls]

        send_msg_log_urls = self.origin_data.get('weixin_msgs').values_list('url', flat=True)
        msg_feed_ids = [re.findall(r'/list/(\w*)', url)[0] for url in send_msg_log_urls]

        return len([val for val in msg_feed_ids if val in user_access_feed_ids])

    def get_submit_feed_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger',
            access_url__contains='/submit_feed/'
        )
        return len(user_log_list)

    def get_add_watch_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger',
            access_url__contains='/add_watch/'
        )
        return len(user_log_list)
Esempio n. 17
0
class WeixinDataDriver(object):
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())

        ret_list = [
            'users', 'weixin_users', 'weixin_msgs', 'all_data_self_members',
            'all_data_manual_service_members', 'user_access_log'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_new_bind_weixin_user_count(self):
        return self.origin_data.get('weixin_users').filter(
            user__date_joined__lte=get_today() -
            datetime.timedelta(days=1)).count()

    def get_new_reg_weixin_user_count(self):
        return self.origin_data.get('weixin_users').filter(
            user__date_joined__gte=get_today() -
            datetime.timedelta(days=1)).count()

    def get_all_new_bind_weixin_user_count(self):
        return self.origin_data.get('weixin_users').count()

    def get_lively_member_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger', ).distinct('user_name')

        self_member_list = self.origin_data.get('all_data_self_members')
        manual_service_member_list = self.origin_data.get(
            'all_data_manual_service_members')
        member_list = []
        member_list.extend(
            self_member_list.values_list('user__username', flat=True))
        member_list.extend(
            manual_service_member_list.values_list('user__username',
                                                   flat=True))
        member_list = set(member_list)

        return len([val for val in user_log_list if val in member_list])

    def get_lively_user_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger', ).distinct('user_name')
        return len(user_log_list)

    def get_send_msg_count(self):
        return self.origin_data.get('weixin_msgs').count()

    def get_click_msg_count(self):

        user_access_urls = self.origin_data.get('user_access_log').filter(
            access_url__contains='/feed_list/').values_list('access_url')
        user_access_feed_ids = [
            re.findall(r'/feed_list/(\w*)', url)[0] for url in user_access_urls
        ]

        send_msg_log_urls = self.origin_data.get('weixin_msgs').values_list(
            'url', flat=True)
        msg_feed_ids = [
            re.findall(r'/list/(\w*)', url)[0] for url in send_msg_log_urls
        ]

        return len(
            [val for val in msg_feed_ids if val in user_access_feed_ids])

    def get_submit_feed_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger',
            access_url__contains='/submit_feed/')
        return len(user_log_list)

    def get_add_watch_count(self):
        user_log_list = self.origin_data.get('user_access_log').filter(
            user_agent__contains='MicroMessenger',
            access_url__contains='/add_watch/')
        return len(user_log_list)
class ResumeDataDriver(object):
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'pub_feeds', 'user_access_log', 'resumes', 'down_resumes',
            'send_cards', 'fav_resumes', 'all_data_user_mark_logs',
            'first_data_staff', 'statistic'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data
        self.staff_list = self.origin_data.get('first_data_staff').values_list(
            'username', flat=True)

    def get_new_recommend_count(self):
        return sum(
            len(data['resumes'])
            for data in self.origin_data.get('pub_feeds').as_pymongo()
            if data['email'] not in self.staff_list)

    def get_new_view_count(self):

        user_log = self.origin_data.get('user_access_log')
        user_list = user_log.filter(access_url__contains='/resumes/display/', )
        # 去除管理员
        ret = [u for u in user_list if u.user_name not in self.staff_list]

        return len(ret)

    def get_new_view_proportion(self):
        return get_proportion(self.get_new_view_count(),
                              self.get_new_recommend_count())

    def get_new_fav_count(self):
        return self.origin_data.get('fav_resumes').exclude(
            user__is_staff=True).count()

    def get_new_down_count(self):
        return self.origin_data.get('resumes').exclude(
            user__is_staff=True).count()

    def get_new_down_proportion(self):
        return get_proportion(self.get_new_down_count(),
                              self.get_new_view_count())

    def get_new_send_card_count(self):
        return self.origin_data.get('send_cards').exclude(
            send_user__is_staff=True).count()

    def get_new_interview_count(self):

        condition = [
            'invite_interview', 'join_interview', 'break_invite', 'send_offer',
            'reject_offer'
        ]
        mark_ids = self.origin_data.get('down_resumes').select_related(
            'ResumeMarkSetting').filter(
                current_mark__code_name__in=condition).values_list(
                    'buy_record', flat=True)

        all_user_mark_logs = self.origin_data.get(
            'all_data_user_mark_logs').select_related(
                'ResumeMarkSetting').filter(
                    mark__code_name__in=condition,
                    mark_time__lte=get_today() -
                    datetime.timedelta(days=1)).exclude(
                        user__is_staff=True).values_list('resume_mark',
                                                         flat=True)

        return len([val for val in mark_ids if val not in all_user_mark_logs])

    def get_new_entered_count(self):
        ret = self.origin_data.get('down_resumes').select_related(
            'ResumeMarkSetting').filter(
                current_mark__code_name__in=['entry']).exclude(
                    buy_record__user__is_staff=True)
        return ret.count()
Esempio n. 19
0
class PartnerDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'tasks',
            'all_data_tasks',
            'upload_resumes',
            'all_data_upload_resumes',
            'task_coin_records',
            'all_data_task_coin_records',
            'do_tasks',
            'all_data_do_tasks'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def do_sql(self, sql_str):
        cursor = connection.cursor()
        cursor.execute(sql_str)
        ret = cursor.fetchone()
        if ret:
            ret = ret[0]
        else:
            ret = 0
        if ret is None:
            ret = 0

        return ret

    def get_accept_task_user_count(self):
        return self.origin_data.get('tasks').values("user__username").distinct().count()

    def get_all_accept_task_user_count(self):
        return self.origin_data.get('all_data_tasks').values("user__username").distinct().count()

    def get_task_total_count(self):
        try:
            url = '{url}{para}'.format(
                url=settings.API_SEARCH_JOB,
                para='?query_feed_result=True&start=0&feed_type=1&need_company=True&time_field_gte=feed_expire_time%3A-7'
            )
            r = requests.get(url=url).json()
            return r.get('total')
        except Exception:
            return 0

    def get_task_viewed_count(self):
        return cache.get('PARTNER_TASK_CHECK_COUNT', 0)

    def get_task_accedpted_count(self):
        return self.origin_data.get('tasks').count()

    def get_task_accedpted_count_contrast(self):
        return get_proportion(self.get_task_accedpted_count(), self.get_task_viewed_count())

    def get_all_task_accedpted_total_count(self):
        return self.origin_data.get('all_data_tasks').count()

    def get_upload_resume_count(self):
        return self.origin_data.get('upload_resumes').count()

    def get_all_upload_resume_count(self):
        return self.origin_data.get('all_data_upload_resumes').count()

    def get_do_task_count(self):
        return self.origin_data.get('do_tasks').count()

    def get_all_do_task_count(self):
        return self.origin_data.get('all_data_do_tasks').count()

    def get_resume_viewed_count(self):
        return self.origin_data.get('task_coin_records').filter(
            record_type='check'
        ).count()

    def get_all_resume_viewed_count(self):
        return self.origin_data.get('all_data_task_coin_records').filter(
            record_type='check'
        ).count()

    def get_resume_download_count(self):
        return self.origin_data.get('task_coin_records').filter(
            record_type='download'
        ).count()

    def get_resume_all_download_count(self):
        return self.origin_data.get('all_data_task_coin_records').filter(
            record_type='download'
        ).count()

    def get_interviewed_count(self):
        return self.origin_data.get('task_coin_records').filter(
            record_type='interview'
        ).count()

    def get_all_interviewed_count(self):
        return self.origin_data.get('all_data_task_coin_records').filter(
            record_type='interview'
        ).count()

    def get_entered_count(self):
        return self.origin_data.get('task_coin_records').filter(
            record_type='taking_work'
        ).count()

    def get_all_entered_count(self):
        return self.origin_data.get('all_data_task_coin_records').filter(
            record_type='taking_work'
        ).count()

    def get_accusation_count(self):
        return self.origin_data.get('task_coin_records').filter(
            record_type='accusation'
        ).count()

    def get_all_accusation_count(self):
        return self.origin_data.get('all_data_task_coin_records').filter(
            record_type='accusation'
        ).count()

    def get_today_commend_and_check_count(self):
        sql_str = """select count(*) from partner_taskcoinrecord , partner_usertaskresume  where
                        partner_taskcoinrecord.record_type = 'check' and
                        partner_taskcoinrecord.task_id = partner_usertaskresume.task_id and
                        partner_taskcoinrecord.upload_resume_id = partner_usertaskresume.resume_id and
                        date_format(partner_taskcoinrecord.record_time,"%Y-%m-%d") = date_format(partner_usertaskresume.upload_time,"%Y-%m-%d") and
                        partner_taskcoinrecord.record_time BETWEEN "{0}" AND "{1}";
                        """.format(
            get_today(),
            get_today() + datetime.timedelta(days=1))

        return self.do_sql(sql_str)

    def get_today_commend_and_download_count(self):
        sql_str = """select count(*) from partner_taskcoinrecord , partner_usertaskresume  where
                        partner_taskcoinrecord.record_type = 'download' and
                        partner_taskcoinrecord.task_id = partner_usertaskresume.task_id and
                        partner_taskcoinrecord.upload_resume_id = partner_usertaskresume.resume_id and
                        date_format(partner_taskcoinrecord.record_time,"%Y-%m-%d") = date_format(partner_usertaskresume.upload_time,"%Y-%m-%d") and
                        partner_taskcoinrecord.record_time BETWEEN "{0}" AND "{1}";
                        """.format(
            get_today(),
            get_today() + datetime.timedelta(days=1))

        return self.do_sql(sql_str)

    def get_today_reward_coin_count(self):
        sql_str = """select sum(coin) from partner_taskcoinrecord where
                      partner_taskcoinrecord.record_time BETWEEN "{0}" AND "{1}";
                        """.format(
            get_today(),
            get_today() + datetime.timedelta(days=1))

        return self.do_sql(sql_str)

    def get_all_reward_coin_count(self):
        sql_str = """select sum(coin) from partner_taskcoinrecord where
                      partner_taskcoinrecord.record_time BETWEEN "{0}" AND "{1}";
                        """.format(
            '2015-06-01',
            get_today() + datetime.timedelta(days=1))

        return self.do_sql(sql_str)

    def get_today_extra_reward_coin_count(self):
        sql_str = """select sum(coin) from partner_taskcoinrecord where
                         (record_type = 'extra_taking_work' or record_type = 'extra_interview' or record_type = 'extra_download') and
                         partner_taskcoinrecord.record_time BETWEEN "{0}" AND "{1}";
                        """.format(
            get_today(),
            get_today() + datetime.timedelta(days=1))
        return self.do_sql(sql_str)

    def get_all_extra_reward_coin_count(self):
        sql_str = """select sum(coin) from partner_taskcoinrecord where
                         (record_type = 'extra_taking_work' or record_type = 'extra_interview' or record_type = 'extra_download') and
                         partner_taskcoinrecord.record_time BETWEEN "{0}" AND "{1}";
                        """.format(
            '2015-06-01',
            get_today() + datetime.timedelta(days=1))
        return self.do_sql(sql_str)
Esempio n. 20
0
class UserDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'users',
            'all_data_users',
            'first_data_users',
            'experience_users',
            'all_data_experience_users',
            'members',
            'all_data_members',
            'self_members',
            'all_data_self_members',
            'manual_service_members',
            'all_data_manual_service_members',
            'user_access_log'
        ]
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_new_register_user_count(self):
        return self.origin_data.get('users').count()

    def get_new_experience_user_count(self):
        return self.origin_data.get('experience_users').count()

    def get_new_member_user_count(self):
        return len(self.origin_data.get('members'))

    def get_new_self_member_user_count(self):
        return self.origin_data.get('self_members').count()

    def get_new_manual_member_user_count(self):
        return self.origin_data.get('manual_service_members').count()

    def get_all_active_user_count(self):
        ret = self.origin_data.get('first_data_users').filter(
            user__is_active=True
        )
        return ret.count()

    def get_all_register_user_count(self):
        return self.origin_data.get('all_data_users').count()

    def get_all_experience_user_count(self):
        return self.origin_data.get('all_data_experience_users').count()

    def get_all_member_user_count(self):
        return len(self.origin_data.get('all_data_members'))

    def get_all_self_member_user_count(self):
        return self.origin_data.get('all_data_self_members').count()

    def get_all_manual_member_user_count(self):
        return self.origin_data.get('all_data_manual_service_members').count()
Esempio n. 21
0
class ResumeDataDriver(object):
    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time',
                                      get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = [
            'pub_feeds', 'statistic', 'feed_result', 'resumes', 'down_resumes',
            'send_cards', 'fav_resumes', 'all_data_user_mark_logs',
            'first_data_staffs'
        ]
        self.db_builder = DataBuilder(start_query_time,
                                      end_query_time,
                                      ret_list=ret_list)
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_staff_list(self):
        return self.origin_data.get('first_data_staffs').values_list(
            'username', flat=True)

    def get_new_recommend_count(self):

        ret = self.origin_data.get('feed_result')
        return len(ret)
        #return sum(len(data['resumes']) for data in self.origin_data.get('pub_feeds').as_pymongo())

    def get_new_view_count(self):
        staffs = self.get_staff_list()
        user_log = self.origin_data.get('statistic')

        user_log = user_log.filter(page_id='40', ).values_list(
            'username', 'access_url')

        u_count = {}
        for u in user_log:
            key = '{0},{1}'.format(u[0], u[1])
            u_count[key] = 1

        return len(u_count)

    def get_new_view_proportion(self):
        return get_proportion(self.get_new_view_count(),
                              self.get_new_recommend_count())

    def get_new_fav_count(self):
        user_log = self.origin_data.get('statistic')

        user_log = user_log.filter(page_id='50', )
        return len(user_log)
        #return self.origin_data.get('fav_resumes').count()

    def get_new_down_count(self):
        return self.origin_data.get('resumes').count()

    def get_new_down_proportion(self):
        return get_proportion(self.get_new_down_count(),
                              self.get_new_view_count())

    def get_new_send_card_count(self):
        return self.origin_data.get('send_cards').count()

    def get_new_interview_count(self):

        condition = [
            'invite_interview', 'join_interview', 'break_invite', 'send_offer',
            'reject_offer'
        ]
        mark_ids = self.origin_data.get('down_resumes').select_related(
            'ResumeMarkSetting').filter(
                current_mark__code_name__in=condition).values_list(
                    'buy_record', flat=True)

        all_user_mark_logs = self.origin_data.get(
            'all_data_user_mark_logs').select_related(
                'ResumeMarkSetting').filter(
                    mark__code_name__in=condition,
                    mark_time__lte=get_today() -
                    datetime.timedelta(days=1)).values_list('resume_mark',
                                                            flat=True)

        return len([val for val in mark_ids if val not in all_user_mark_logs])

    def get_new_entered_count(self):
        ret = self.origin_data.get('down_resumes').select_related(
            'ResumeMarkSetting').filter(current_mark__code_name__in=['entry'])
        return ret.count()
class ResumeDataDriver(object):

    def __init__(self, **kwargs):

        start_query_time = kwargs.get('start_query_time', get_today() - datetime.timedelta(days=1))
        end_query_time = kwargs.get('end_query_time', get_today())
        ret_list = ['pub_feeds', 'statistic', 'feed_result', 'resumes', 'down_resumes', 'send_cards', 'fav_resumes', 'all_data_user_mark_logs', 'first_data_staffs']
        self.db_builder = DataBuilder(
            start_query_time,
            end_query_time,
            ret_list=ret_list
        )
        self.db_builder.build_data()
        self.origin_data = self.db_builder.origin_data

    def get_staff_list(self):
        return self.origin_data.get('first_data_staffs').values_list('username', flat=True)

    def get_new_recommend_count(self):

        ret = self.origin_data.get('feed_result')
        return len(ret)
        #return sum(len(data['resumes']) for data in self.origin_data.get('pub_feeds').as_pymongo())

    def get_new_view_count(self):
        staffs = self.get_staff_list()
        user_log = self.origin_data.get('statistic')

        user_log = user_log.filter(
            page_id='40',
        ).values_list('username', 'access_url')

        u_count = {}
        for u in user_log:
            key = '{0},{1}'.format(u[0], u[1])
            u_count[key] = 1

        return len(u_count)

    def get_new_view_proportion(self):
        return get_proportion(self.get_new_view_count(), self.get_new_recommend_count())

    def get_new_fav_count(self):
        user_log = self.origin_data.get('statistic')

        user_log = user_log.filter(
            page_id='50',
        )
        return len(user_log)
        #return self.origin_data.get('fav_resumes').count()

    def get_new_down_count(self):
        return self.origin_data.get('resumes').count()

    def get_new_down_proportion(self):
        return get_proportion(self.get_new_down_count(), self.get_new_view_count())

    def get_new_send_card_count(self):
        return self.origin_data.get('send_cards').count()

    def get_new_interview_count(self):

        condition = [
            'invite_interview',
            'join_interview',
            'break_invite',
            'send_offer',
            'reject_offer'
        ]
        mark_ids = self.origin_data.get('down_resumes').select_related('ResumeMarkSetting').filter(
            current_mark__code_name__in=condition
        ).values_list('buy_record', flat=True)

        all_user_mark_logs = self.origin_data.get('all_data_user_mark_logs').select_related('ResumeMarkSetting').filter(
            mark__code_name__in=condition,
            mark_time__lte=get_today() - datetime.timedelta(days=1)
        ).values_list('resume_mark', flat=True)

        return len([val for val in mark_ids if val not in all_user_mark_logs])

    def get_new_entered_count(self):
        ret = self.origin_data.get('down_resumes').select_related('ResumeMarkSetting').filter(
            current_mark__code_name__in=[
                'entry'
            ]
        )
        return ret.count()