logs-fixes

This commit is contained in:
tonyrewin 2022-11-22 09:20:01 +03:00
parent 8b0a5ed035
commit 11710218b9
3 changed files with 25 additions and 20 deletions

View File

@ -155,18 +155,17 @@ async def migrate(entry, storage):
r["deletedAt"] = date_parse(entry["deletedAt"])
# topics
category = entry["category"]
mainTopic = topics_by_oid.get(category)
if mainTopic:
r["mainTopic"] = storage["replacements"].get(mainTopic["slug"], mainTopic["slug"])
topic_oids = [category, ]
topic_oids.extend(entry.get("tags", []))
for oid in topic_oids:
if oid in storage["topics"]["by_oid"]:
r["topics"].add(storage["topics"]["by_oid"][oid]["slug"])
else:
print("[migration] unknown old topic id: " + oid)
category = entry.get("category")
for oid in [category, ] + entry.get("tags", []):
t = storage["topics"]["by_oid"].get(oid)
if t:
tslug = storage["topics"]["by_oid"][oid]["slug"]
r["topics"].add(tslug)
r["topics"] = list(r["topics"])
# main topic
mt = topics_by_oid.get(category)
if mt and mt.get("slug"):
r["mainTopic"] = storage["replacements"].get(mt["slug"]) or r["topics"][0]
# add author as TopicFollower
with local_session() as session:
@ -187,8 +186,10 @@ async def migrate(entry, storage):
)
session.add(tf)
except IntegrityError:
print('[migration.shout] skipped by topic ' + tpc)
return
print('[migration.shout] hidden by topic ' + tpc)
r["visibility"] = "authors"
r["publishedAt"] = None
r["topics"].remove(tpc)
entry["topics"] = r["topics"]
entry["cover"] = r["cover"]
@ -196,7 +197,7 @@ async def migrate(entry, storage):
# body
r["body"], media = prepare_html_body(entry)
if media:
r["media"] = json.dumps(media)
r["media"] = json.dumps(media, ensure_ascii=True)
# save shout to db
s = object()
shout_dict = r.copy()

View File

@ -596,6 +596,7 @@
"r-b": "rnb",
"rasizm": "racism",
"realizm": "realism",
"redaktura": "editing",
"refleksiya": "reflection",
"reggi": "reggae",
"religion": "religion",

View File

@ -102,12 +102,15 @@ class ViewedStorage:
@staticmethod
async def init():
self = ViewedStorage
async with self.lock:
self.client = create_client({
"Authorization": "Bearer %s" % str(token)
}, schema=schema_str)
print("[stat.viewed] authorized permanentely by ackee.discours.io: %s" % token)
if token:
self = ViewedStorage
async with self.lock:
self.client = create_client({
"Authorization": "Bearer %s" % str(token)
}, schema=schema_str)
print("[stat.viewed] authorized permanentely by ackee.discours.io: %s" % token)
else:
print("[stat.viewed] please, set ACKEE_TOKEN")
@staticmethod
async def update(session):