Commit f4fea10d authored by 段英荣's avatar 段英荣

Merge branch 'master' into 'test'

Master

See merge request !306
parents f90de1e8 4f0b28b4
...@@ -24,29 +24,5 @@ ...@@ -24,29 +24,5 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" /> <option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings> </formatting-settings>
</DBN-SQL> </DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme> </code_scheme>
</component> </component>
\ No newline at end of file
...@@ -288,25 +288,40 @@ class ESPerform(object): ...@@ -288,25 +288,40 @@ class ESPerform(object):
def get_tag_topic_list(cls, tag_id, have_read_topic_id_list, size=100): def get_tag_topic_list(cls, tag_id, have_read_topic_id_list, size=100):
try: try:
functions_list = list() functions_list = list()
for id in tag_id: # for id in tag_id:
functions_list.append( # functions_list.append(
{ # {
"filter": {"term": {"tag_list": id}}, # "filter": {"term": {"tag_list": id}},
"weight": 1 # "weight": 1
} # }
) # )
functions_list += [ functions_list += [
{ {
"filter": {"term": {"content_level": 6}}, "filter": {
"weight": 6000 "constant_score":{
"filter":{
"term": {"content_level": 6}}
}
},
"weight": 60
}, },
{ {
"filter": {"term": {"content_level": 5}}, "filter": {
"weight": 5000 "constant_score":{
"filter":{
"term": {"content_level": 5}}
}
},
"weight": 50
}, },
{ {
"filter": {"term": {"content_level": 4}}, "filter": {
"weight": 4000 "constant_score":{
"filter":{
"term": {"content_level": 4}}
}
},
"weight": 40
} }
] ]
q = { q = {
...@@ -333,7 +348,7 @@ class ESPerform(object): ...@@ -333,7 +348,7 @@ class ESPerform(object):
"sort": [ "sort": [
{"_score": {"order": "desc"}}, {"_score": {"order": "desc"}},
{"create_time_val": {"order": "desc"}}, {"create_time_val": {"order": "desc"}},
{"language_type": {"order": "asc"}}, # {"language_type": {"order": "asc"}},
] ]
} }
if len(have_read_topic_id_list) > 0: if len(have_read_topic_id_list) > 0:
......
...@@ -103,12 +103,9 @@ class CollectData(object): ...@@ -103,12 +103,9 @@ class CollectData(object):
if len(recommend_topic_id_list)==0 and cursor==0 and len(redis_topic_list)>0: if len(recommend_topic_id_list)==0 and cursor==0 and len(redis_topic_list)>0:
have_read_topic_id_list.extend(redis_topic_list[:2]) have_read_topic_id_list.extend(redis_topic_list[:2])
if len(tag_id_list) > 0: if len(new_user_click_tag_list)>0:
if len(new_user_click_tag_list)>0:
tag_topic_id_list = ESPerform.get_tag_topic_list(new_user_click_tag_list, have_read_topic_id_list) tag_topic_id_list = ESPerform.get_tag_topic_list(new_user_click_tag_list, have_read_topic_id_list)
logging.warning("tag_topic_id_list:%s" % str(new_user_click_tag_list)) else:
logging.warning("tag_id_list:%s" % str(tag_id_list))
else:
tag_topic_id_list = ESPerform.get_tag_topic_list(tag_id_list,have_read_topic_id_list) tag_topic_id_list = ESPerform.get_tag_topic_list(tag_id_list,have_read_topic_id_list)
...@@ -251,9 +248,7 @@ class CollectData(object): ...@@ -251,9 +248,7 @@ class CollectData(object):
else: else:
tagid_list = list() tagid_list = list()
logging.warning("unknown type msg:%s" % raw_val_dict.get("type", "missing type")) logging.warning("unknown type msg:%s" % raw_val_dict.get("type", "missing type"))
logging.info(
"consume click topic_id:%s,device_id:%s" % (
str(tagid_list), str(device_id)))
device_id = raw_val_dict["device"]["device_id"] device_id = raw_val_dict["device"]["device_id"]
user_id = raw_val_dict["user_id"] if "user_id" in raw_val_dict else None user_id = raw_val_dict["user_id"] if "user_id" in raw_val_dict else None
......
...@@ -177,32 +177,28 @@ class TopicUtils(object): ...@@ -177,32 +177,28 @@ class TopicUtils(object):
}, },
{ {
"filter": { "filter": {
"term": { "constant_score":{
"content_level": 6 "filter":{
} "term": {
}, "content_level": 6
"weight": 1000 }
}, }
{
"filter": {
"term": {
"is_excellent": 1
} }
}, },
"weight": 500 "weight": 600
} }
] ]
if len(user_similar_score_list) > 0: # if len(user_similar_score_list) > 0:
for item in user_similar_score_list[:100]: # for item in user_similar_score_list[:100]:
score_item = 2 + item[1] # score_item = 2 + item[1]
functions_list.append( # functions_list.append(
{ # {
"filter": {"bool": { # "filter": {"bool": {
"should": {"term": {"user_id": item[0]}}}}, # "should": {"term": {"user_id": item[0]}}}},
"weight": score_item, # "weight": score_item,
} # }
) # )
if len(attention_user_id_list) > 0: if len(attention_user_id_list) > 0:
functions_list.append( functions_list.append(
......
...@@ -155,7 +155,7 @@ def choice_push_tag(device_id, user_id): ...@@ -155,7 +155,7 @@ def choice_push_tag(device_id, user_id):
@bind("physical/search/identity_tag_name") @bind("physical/search/identity_tag_name")
def identity_tag_name(topic_content): def identity_tag_name(topic_content):
try: try:
ret_tag_list = list() ret_tag_set = set()
redis_key_name = "physical:tag_name_set" redis_key_name = "physical:tag_name_set"
body = { body = {
...@@ -171,9 +171,9 @@ def identity_tag_name(topic_content): ...@@ -171,9 +171,9 @@ def identity_tag_name(topic_content):
token_word = item["token"] token_word = item["token"]
is_member = redis_client.sismember(redis_key_name, token_word) is_member = redis_client.sismember(redis_key_name, token_word)
if is_member: if is_member:
ret_tag_list.append(token_word) ret_tag_set.add(token_word)
return {"tag_name_list": ret_tag_list} return {"tag_name_list": list(ret_tag_set)}
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"tag_name_list": []} return {"tag_name_list": []}
......
...@@ -73,10 +73,10 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query ...@@ -73,10 +73,10 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
if offset>0: # 首次搜索时不需要过滤已读 if offset>0: # 首次搜索时不需要过滤已读
have_read_topic_id_list = list(json.loads(redis_field_val_list[0])) have_read_topic_id_list = list(json.loads(redis_field_val_list[0]))
user_similar_score_redis_key = "physical:user_similar_score:user_id:" + str(user_id) # user_similar_score_redis_key = "physical:user_similar_score:user_id:" + str(user_id)
redis_user_similar_score_redis_val = redis_client.get(user_similar_score_redis_key) # redis_user_similar_score_redis_val = redis_client.get(user_similar_score_redis_key)
user_similar_score_redis_list = json.loads( # user_similar_score_redis_list = json.loads(
redis_user_similar_score_redis_val) if redis_user_similar_score_redis_val else [] # redis_user_similar_score_redis_val) if redis_user_similar_score_redis_val else []
attention_tag_list = list() attention_tag_list = list()
recommend_topic_list = list() recommend_topic_list = list()
...@@ -113,8 +113,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query ...@@ -113,8 +113,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
topic_id_list = list() topic_id_list = list()
rank_topic_id_list = TopicUtils.get_recommend_topic_ids(user_id=user_id, tag_id=tag_id, offset=0, size=size, rank_topic_id_list = TopicUtils.get_recommend_topic_ids(user_id=user_id, tag_id=tag_id, offset=0, size=size,
single_size=size,query=query, query_type=query_type, single_size=size,query=query, query_type=query_type,
filter_topic_id_list=have_read_topic_id_list, filter_topic_id_list=have_read_topic_id_list,index_type="topic-high-star",routing="4,5,6",attention_tag_list=attention_tag_list)
user_similar_score_list=user_similar_score_redis_list,index_type="topic-high-star",routing="4,5,6",attention_tag_list=attention_tag_list)
if len(recommend_topic_list) == 6 and query is None: if len(recommend_topic_list) == 6 and query is None:
if (size < 11): if (size < 11):
......
...@@ -209,7 +209,7 @@ class Topic(models.Model): ...@@ -209,7 +209,7 @@ class Topic(models.Model):
user_query_results = UserExtra.objects.using(settings.SLAVE_DB_NAME).filter(user_id=self.user_id) user_query_results = UserExtra.objects.using(settings.SLAVE_DB_NAME).filter(user_id=self.user_id)
if user_query_results.count() > 0: if user_query_results.count() > 0:
if user_query_results[0].is_recommend: if user_query_results[0].is_recommend:
offline_score += 2.0 offline_score += 2.0 *10
elif user_query_results[0].is_shadow: elif user_query_results[0].is_shadow:
user_is_shadow = True user_is_shadow = True
...@@ -219,18 +219,18 @@ class Topic(models.Model): ...@@ -219,18 +219,18 @@ class Topic(models.Model):
# 帖子等级 # 帖子等级
if self.content_level == '5': if self.content_level == '5':
offline_score += 6.0 offline_score += 100.0 *3
elif self.content_level == '4': elif self.content_level == '4':
offline_score += 5.0 offline_score += 60.0 *3
elif self.content_level == '6': elif self.content_level == '6':
offline_score += 400.0 offline_score += 200.0 *3
is_excellent = self.judge_if_excellent_topic(self.id) # is_excellent = self.judge_if_excellent_topic(self.id)
if is_excellent: # if is_excellent:
offline_score += 200.0 # offline_score += 200.0
if self.language_type == 1: if self.language_type == 1:
offline_score += 100.0 offline_score += 60.0
# exposure_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=1).count() # exposure_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=1).count()
# click_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=2).count() # click_count = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=2).count()
# uv_num = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=3).count() # uv_num = ActionSumAboutTopic.objects.using(settings.SLAVE_DB_NAME).filter(topic_id=self.id, data_type=3).count()
......
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