def add_manual_feed_result(request): """ @summary: 向订阅添加人工的结果 """ p = request.POST feed_id = p.get('feed_id') url = p.get('url') username = p.get('username') or request.user.username recommend = p.get('recommend', True) user = request.user if not recommend: recommend = False feed = ObjectId(feed_id) x_pinbot_admin_auth = request.META.get('HTTP_X_PINBOT_ADMIN_AUTH', '') if x_pinbot_admin_auth != PINBOT_ADMIN_AUTH_DICT['x-pinbot-admin-auth'] and not user.is_staff: data = produce_return_json(data=' x_pinbot_admin_auth is error', status=False) elif feed_id and url: try: resume = get_resume_from_url(url) try: if resume.update_time.find("-") > 0: resume_update_time = datetime.datetime.strptime(resume.update_time, "%Y-%m-%d") elif resume.update_time.find("/") > 0: resume_update_time = datetime.datetime.strptime(resume.update_time, "%Y/%m/%d") else: resume_update_time = datetime.datetime.today() except : resume_update_time = datetime.datetime.today() if resume: ManualPushResume(username=username, feed=feed, resume=resume, url=url, reco_index=300).save() feed_results = FeedResult.objects.filter(feed=feed, resume=resume) if feed_results: for feed_result in feed_results: # 判断是否用户自己已经屏蔽过了 if feed_result.is_manual and feed_result.is_recommended == False: data = produce_return_json(data='用户已经被人工屏蔽过了,这条推荐没有保存', status=False) break elif feed_result.is_manual == False and feed_result.is_recommended == False: feed_result.is_recommended = recommend feed_result.resume_update_time = resume_update_time feed_result.is_manual = True feed_result.calc_time = get_datetime(hours=12) feed_result.admin = username feed_result.is_staff = 1 if 'hopperclouds.com' in username else 0 feed_result.published = False feed_result.save() data = produce_return_json(data='已经成功修改结果(机器屏蔽数据)', status=False) else: reco_er = '' if '@' in feed_result.admin: reco_er = feed_result.admin else: reco_er = '算法%s_%s' % (feed_result.algorithm, feed_result.admin) hint = "[已推]%s 在 %s[added] 不会强推" % (reco_er, feed_result.calc_time) data = produce_return_json(data = hint , status = False) else: # 管理员,首次添加新的推荐 feed_result = FeedResult(feed=feed, resume=resume, \ is_recommended=recommend, reco_index=300, \ job_related=30) feed_result.resume_update_time = resume_update_time feed_result.is_manual = True feed_result.calc_time = datetime.datetime.today() feed_result.published = False feed_result.admin = username feed_result.is_staff = 1 if 'hopperclouds.com' in username else 0 feed_result.save() data = produce_return_json(data='首次添加成功') else: # 人工添加但是还不能在resumeData中找到 ManualPushResume(username=username, feed=feed, url=url, reco_index=110, has_collected=False).save() data = produce_return_json(data='Pinbot 还没有收集到这个简历.has not collected in pinbot sys', status=False) except Exception, e: data = produce_return_json(data=str(e), status=False)
from models import UserFeed2, UserFeed # user_resume_reads = UserFeed2.objects.filter(username=request.user.username, feed=ObjectId(feed_id)) # for user_resume_read in user_resume_reads: # read_id_list.extend(user_resume_read.read_id_list) read_id_list = UserReadResume.objects.filter(user=request.user, feed_id=str(feed_id)).values_list('resume_id') read_id_list = set([ObjectId(res[0]) for res in read_id_list if res]) view = p.get('view', 'user') if view == 'search_result': print start, feed_id, read_id_list return feed_group_search_ajax(start, feed_id, read_id_list) yestoday_deadline = get_datetime(hours=-10) today_deadline = get_datetime(hours=14) # 该项推荐的所有结果 feed_results = FeedResult.objects.filter(feed=feed_id) # newest_feed_result = feed_results.order_by('-calc_time')[0] all_reco_feed_results = feed_results.filter(is_recommended=True) all_reco_published_feed_results = all_reco_feed_results.filter(published=True) # all_reco_not_published_feed_results = all_reco_feed_results.filter(published=False) # 总计算数 total_count = feed_results.count()