From 2adf4422242f502d002c0ba2deffd2e8ff897357 Mon Sep 17 00:00:00 2001 From: tonyrewin Date: Sun, 27 Nov 2022 11:19:38 +0300 Subject: [PATCH] migration-upgrade --- README.md | 10 +- migration/extract.py | 22 ++- migration/tables/content_items.py | 206 ++++++++++++++++------------- migration/tables/replacements.json | 1 + resolvers/zine/reactions.py | 14 +- 5 files changed, 143 insertions(+), 110 deletions(-) diff --git a/README.md b/README.md index c69428a9..a0b778b2 100644 --- a/README.md +++ b/README.md @@ -24,10 +24,8 @@ apt install redis nginx First, install Postgres. Then you'll need some data ``` - -psql -U postgres -> create database discoursio; -> \q +brew install postgres +createdb discoursio python server.py migrate ``` @@ -42,3 +40,7 @@ python3 server.py dev Put the header 'Authorization' with token from signIn query or registerUser mutation. +# How to debug Ackee + +Set ACKEE_TOKEN var + diff --git a/migration/extract.py b/migration/extract.py index ccadb7e2..5dd7ccba 100644 --- a/migration/extract.py +++ b/migration/extract.py @@ -262,9 +262,12 @@ def extract_md(body, oid=""): def extract_media(entry): ''' normalized media extraction method ''' # media [ { title pic url body } ]} - kind = entry.get("layout") + kind = entry.get("type") + if not kind: + print(entry) + raise Exception("shout no layout") media = [] - for m in entry.get("media", []): + for m in entry.get("media") or []: # title title = m.get("title", "").replace("\n", " ").replace(" ", " ") artist = m.get("performer") or m.get("artist") @@ -274,7 +277,7 @@ def extract_media(entry): # pic url = m.get("fileUrl") or m.get("url", "") pic = "" - if "thumborId" in m: + if m.get("thumborId"): pic = cdn + "/unsafe/1600x/" + m["thumborId"] # url @@ -285,11 +288,8 @@ def extract_media(entry): url = "https://youtube.com/?watch=" + m["youtubeId"] elif "vimeoId" in m: url = "https://vimeo.com/" + m["vimeoId"] - else: - print("[extract] media is not supported") # body - body = m.get("body") or m.get("literatureBody") - + body = m.get("body") or m.get("literatureBody") or "" media.append({ "url": url, "pic": pic, @@ -306,7 +306,7 @@ def prepare_html_body(entry): addon = "" if kind == "Video": addon = "" - for m in entry.get("media", []): + for m in entry.get("media") or []: if "youtubeId" in m: addon += '