Commit 9899ea77 authored by zwild's avatar zwild

topic detail order

parent 76dd662e
# -*- coding: UTF-8 -*-
# !/usr/bin/env python
from kafka import KafkaConsumer from kafka import KafkaConsumer
import random import random
from libs.cache import redis_client from libs.cache import redis_client
...@@ -633,7 +630,7 @@ class CollectData(object): ...@@ -633,7 +630,7 @@ class CollectData(object):
logging.info("action=api/v1/cards/topic") logging.info("action=api/v1/cards/topic")
tag_name = data["APP"].get("query", []) tag_name = data["APP"].get("query", [])
tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter( tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter(
name=tag_name).values_list("id")) name=tag_name).values_list("id", flat=True))
device_id = data["SYS"]["cl_id"] device_id = data["SYS"]["cl_id"]
user_id = data['SYS'].get('user_id', None) user_id = data['SYS'].get('user_id', None)
self.transfer_update_recommend_tag_list(device_id, user_feature, user_id, self.transfer_update_recommend_tag_list(device_id, user_feature, user_id,
...@@ -651,7 +648,7 @@ class CollectData(object): ...@@ -651,7 +648,7 @@ class CollectData(object):
tag_ids = list(data["APP"].get("tag_ids", [])) tag_ids = list(data["APP"].get("tag_ids", []))
tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter( tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter(
id__in=tag_ids, is_online=True, is_deleted=False, id__in=tag_ids, is_online=True, is_deleted=False,
is_category=False).values_list("id")) is_category=False).values_list("id", flat=True))
device_id = data["SYS"]["cl_id"] device_id = data["SYS"]["cl_id"]
user_id = data['SYS'].get('user_id', None) user_id = data['SYS'].get('user_id', None)
self.transfer_update_recommend_tag_list(device_id, user_feature, user_id, self.transfer_update_recommend_tag_list(device_id, user_feature, user_id,
...@@ -668,7 +665,7 @@ class CollectData(object): ...@@ -668,7 +665,7 @@ class CollectData(object):
tag_ids = list(data["APP"].get("tag_ids", [])) tag_ids = list(data["APP"].get("tag_ids", []))
tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter( tag_list = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter(
id__in=tag_ids, is_online=True, is_deleted=False, id__in=tag_ids, is_online=True, is_deleted=False,
is_category=False).values_list("id")) is_category=False).values_list("id", flat=True))
device_id = data["SYS"]["cl_id"] device_id = data["SYS"]["cl_id"]
user_id = data['SYS'].get('user_id', None) user_id = data['SYS'].get('user_id', None)
self.transfer_update_recommend_tag_list(device_id, user_feature, user_id, self.transfer_update_recommend_tag_list(device_id, user_feature, user_id,
...@@ -685,7 +682,7 @@ class CollectData(object): ...@@ -685,7 +682,7 @@ class CollectData(object):
logging.info('action:%s,tag_list:%s' % (action, str(tag_ids))) logging.info('action:%s,tag_list:%s' % (action, str(tag_ids)))
tag_query_results = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter( tag_query_results = list(Tag.objects.using(settings.SLAVE1_DB_NAME).filter(
id__in=tag_ids, is_online=True, is_deleted=False, id__in=tag_ids, is_online=True, is_deleted=False,
is_category=False).values_list("id")) is_category=False).values_list("id", flat=True))
tag_query_results = [i[0] for i in tag_query_results] tag_query_results = [i[0] for i in tag_query_results]
logging.info('action:%s,mysql query taglist:%s' % (action, str(tag_query_results))) logging.info('action:%s,mysql query taglist:%s' % (action, str(tag_query_results)))
tag_query_results_multi = [i for i in tag_ids if i in tag_query_results] tag_query_results_multi = [i for i in tag_ids if i in tag_query_results]
......
...@@ -359,7 +359,7 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10, sort_type=PICTORIAL ...@@ -359,7 +359,7 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10, sort_type=PICTORIAL
if sort_type == PICTORIAL_TOPIC_SORT.HOT: if sort_type == PICTORIAL_TOPIC_SORT.HOT:
q["sort"] = [ q["sort"] = [
{"related_billboard.total_vote_cnt": { {"related_billboard.real_vote_cnt": {
"order": "desc", "order": "desc",
"nested_path": "related_billboard", "nested_path": "related_billboard",
"missing": "_last", "missing": "_last",
...@@ -403,7 +403,7 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10, sort_type=PICTORIAL ...@@ -403,7 +403,7 @@ def pictorial_topic_sort(pictorial_id=-1, offset=0, size=10, sort_type=PICTORIAL
# }} # }}
# ] # ]
q["sort"] = [ q["sort"] = [
{"related_billboard.total_vote_cnt": { {"related_billboard.real_vote_cnt": {
"order": "desc", "order": "desc",
"nested_path": "related_billboard", "nested_path": "related_billboard",
"missing": "_last", "missing": "_last",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment