Commit 4b6e0c84 authored by zhanglu's avatar zhanglu

Merge branch 'hotfix/pin' into 'test'

Hotfix/pin

See merge request alpha/saturn!36
parents a42d1344 41446ab6
...@@ -9,7 +9,7 @@ from alpha_types.venus import ERROR as CODES ...@@ -9,7 +9,7 @@ from alpha_types.venus import ERROR as CODES
from alpha_types.venus import GRAP_PLATFORM from alpha_types.venus import GRAP_PLATFORM
ins_account_cache = "ins_account_cache" topic_id_cache = "ins_account_cache"
class CreateTopicForBatch(BaseView): class CreateTopicForBatch(BaseView):
...@@ -23,7 +23,7 @@ class CreateTopicForBatch(BaseView): ...@@ -23,7 +23,7 @@ class CreateTopicForBatch(BaseView):
card_level = request.POST.get("card_level", 0) card_level = request.POST.get("card_level", 0)
tag_id = request.POST.get("tag_id") tag_id = request.POST.get("tag_id")
is_online = request.POST.get("is_online", 0) is_online = request.POST.get("is_online", 0)
platform = request.POST.get("platform") platform = int(request.POST.get("platform"))
topic_list = json.loads(request.POST.get("topic_list", '[]')) topic_list = json.loads(request.POST.get("topic_list", '[]'))
if not user_id: if not user_id:
...@@ -69,19 +69,26 @@ class CreateTopicForBatch(BaseView): ...@@ -69,19 +69,26 @@ class CreateTopicForBatch(BaseView):
not_exists_ids = [] not_exists_ids = []
topic_list = [] topic_list = []
if platform == GRAP_PLATFORM.INS: if platform == GRAP_PLATFORM.INS:
cache_key = topic_id_cache
elif platform == GRAP_PLATFORM.PIN:
cache_key = topic_id_cache + ":2"
else:
return
if platform in (GRAP_PLATFORM.INS, GRAP_PLATFORM.PIN):
for item in topics: for item in topics:
_id = item.get("id") _id = item.get("id")
if not _id: if not _id:
continue continue
exists = ins_cache.sismember(ins_account_cache, _id) exists = ins_cache.sismember(cache_key, _id)
if exists: if exists:
continue continue
item["platform"] = platform
item["platform_id"] = _id
topic_list.append(item) topic_list.append(item)
not_exists_ids.append(_id) not_exists_ids.append(_id)
else:
topic_list = topics
# check_info = Sensitive.check(tag_names) # check_info = Sensitive.check(tag_names)
# tags = [tag_name for tag_name, succ in check_info.items() if not succ] # tags = [tag_name for tag_name, succ in check_info.items() if not succ]
...@@ -121,7 +128,7 @@ class CreateTopicForBatch(BaseView): ...@@ -121,7 +128,7 @@ class CreateTopicForBatch(BaseView):
# 将已经跑了的数据添加到缓存 # 将已经跑了的数据添加到缓存
if not_exists_ids: if not_exists_ids:
ins_cache.sadd(ins_account_cache, *not_exists_ids) ins_cache.sadd(cache_key, *not_exists_ids)
return self.ok(data=result) return self.ok(data=result)
......
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