Esempio n. 1
0
    def query_api(self):
        keywords = self.request.GET.get(self.keywords_param, '')
        fields = self.request.GET.get(self.fields_param, '')

        if not keywords:
            return {}

        if fields not in ('position_title', 'company_name', 'name', 'school', 'all'):
            return {}

        resume_id_str = self.get_resume_id_str()
        query_size = self.get_resume_size(resume_id_str)
        search_params = {
            'size': query_size,
            'start': 0,
            'keywords': keywords,
            'search_fields': fields,
            'ids_list': resume_id_str
        }
        if fields == 'all':
            search_params.pop('search_fields', None)

        search_result = ParseUtils.search_resume(search_params)
        resume_data = search_result.get('data', {}).get('results', [])
        search_id_list = [i['id'] for i in resume_data if i.get('id')]
        return {
            self.resume_id_key: search_id_list,
        }
Esempio n. 2
0
    def get_query_keyword(self):
        keyword = self.request.GET.get('query', '')
        if not keyword:
            return {}

        page = get_int(self.request.GET.get('page', 0))
        page = 0 if page - 1 < 0 else page - 1
        owner = self.request.user.username

        search_params = {
            'owners': owner,
            'size': 100,
            'start': 0,
            'keywords': keyword,
        }
        search_result = ParseUtils.search_resume(search_params)
        resume_data = search_result.get('data', {}).get('results', [])
        return {'resume_id__in': [i['id'] for i in resume_data if i.get('id')]}
Esempio n. 3
0
    def get_query_advance(self, query_cond):
        work_years = self.get_advance_work_years()
        degree = self.get_advance_degree()
        gender = self.get_advance_gender()
        age = self.get_advance_age()
        current_area = self.get_current_area()
        salary = self.get_advance_salary()

        not_query_advance = (not work_years and not degree and not gender
                             and not age and not current_area and not salary)
        if not_query_advance:
            return query_cond

        feed_oid = get_oid(self.kwargs.get('feed_id'))
        feed_resumes = list(
            FeedResult.objects.filter(
                feed=feed_oid,
                published=True,
                is_recommended=True,
            ).order_by('-display_time').limit(500).only('resume').as_pymongo())
        ids_list = [str(i['resume']) for i in feed_resumes]

        search_params = {
            'work_years': work_years,
            'degree': degree,
            'gender': gender,
            'age': age,
            'current_area': current_area,
            'salary': salary,
            'size': 100,
            'ids_list': ','.join(ids_list),
        }
        result = ParseUtils.search_resume(search_params)
        resume_data = result.get('data', {}).get('results', [])

        if result.get('status') != 'ok':
            return query_cond

        query_cond.update({
            'resume__in':
            [get_oid(i['id']) for i in resume_data if i.get('id')]
        })

        return query_cond
Esempio n. 4
0
    def get_query_keyword(self):
        keyword = self.request.GET.get('query', '')
        if not keyword:
            return {}

        page = get_int(self.request.GET.get('page', 0))
        page = 0 if page - 1 < 0 else page - 1
        owner = self.request.user.username

        search_params = {
            'owners': owner,
            'size': 100,
            'start': 0,
            'keywords': keyword,
        }
        search_result = ParseUtils.search_resume(search_params)
        resume_data = search_result.get('data', {}).get('results', [])
        return {
            'resume_id__in': [i['id'] for i in resume_data if i.get('id')]
        }
Esempio n. 5
0
    def get_api_query(self):
        api_param = {}
        keywords = self.request.GET.get('resume_keywords', '')
        if keywords:
            api_param['keywords'] = keywords

        city = self.request.GET.get('city', '')
        if city:
            api_param['current_area'] = city

        expect_city = self.request.GET.get('expect_city', '')
        if expect_city:
            api_param['expectation_area'] = expect_city

        hunting_state = self.request.GET.get('job_hunting_state', '')
        if hunting_state in ('求职', '观望', '稳定', '应届'):
            api_param['job_hunting_state'] = hunting_state

        work_years = self.get_work_years()
        if work_years:
            api_param['work_years'] = work_years

        search_fields = self.request.GET.getlist('search_fields', [])
        if search_fields:
            api_param['search_fields'] = ','.join(search_fields)

        if not api_param:
            return {}

        api_param['size'] = 200
        api_param['has_contact_info'] = 'yes'
        result = ParseUtils.search_resume(api_param)
        resume_data = result.get('data', {}).get('results', [])

        if not resume_data:
            return {}

        query = {
            'resume_id__in': [i['id'] for i in resume_data if i.get('id')]
        }
        return query