migration-usable
This commit is contained in:
parent
8a7d062eb4
commit
0ba5047ff9
|
@ -22,8 +22,12 @@ on debian/ubuntu
|
||||||
apt install redis nginx
|
apt install redis nginx
|
||||||
```
|
```
|
||||||
|
|
||||||
Then run nginx, redis and API server
|
First, you'll need some data
|
||||||
|
```
|
||||||
|
python server.py migrate
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run nginx, redis and API server
|
||||||
```
|
```
|
||||||
redis-server
|
redis-server
|
||||||
|
|
||||||
|
@ -32,7 +36,6 @@ nginx -s reload
|
||||||
|
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
python server.py
|
python server.py
|
||||||
python server.py inbox
|
|
||||||
```
|
```
|
||||||
|
|
||||||
# How to do an authorized request
|
# How to do an authorized request
|
||||||
|
|
|
@ -6,14 +6,14 @@ import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
# from export import export_email_subscriptions
|
# from export import export_email_subscriptions
|
||||||
from export import export_mdx, export_slug
|
from .export import export_mdx, export_slug
|
||||||
from orm.reaction import Reaction
|
from orm.reaction import Reaction
|
||||||
from tables.users import migrate as migrateUser
|
from .tables.users import migrate as migrateUser
|
||||||
from tables.users import migrate_2stage as migrateUser_2stage
|
from .tables.users import migrate_2stage as migrateUser_2stage
|
||||||
from tables.content_items import get_shout_slug, migrate as migrateShout
|
from .tables.content_items import get_shout_slug, migrate as migrateShout
|
||||||
from tables.topics import migrate as migrateTopic
|
from .tables.topics import migrate as migrateTopic
|
||||||
from tables.comments import migrate as migrateComment
|
from .tables.comments import migrate as migrateComment
|
||||||
from tables.comments import migrate_2stage as migrateComment_2stage
|
from .tables.comments import migrate_2stage as migrateComment_2stage
|
||||||
|
|
||||||
from settings import DB_URL
|
from settings import DB_URL
|
||||||
|
|
||||||
|
@ -301,5 +301,4 @@ def migrate():
|
||||||
print('[migration] usage: python migrate.py <command>')
|
print('[migration] usage: python migrate.py <command>')
|
||||||
print('[migration] commands: mongodb, bson, all, all mdx, - <slug>')
|
print('[migration] commands: mongodb, bson, all, all mdx, - <slug>')
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
migrate()
|
migrate()
|
|
@ -2,7 +2,7 @@ import os
|
||||||
import bson
|
import bson
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from utils import DateTimeEncoder
|
from .utils import DateTimeEncoder
|
||||||
|
|
||||||
def json_tables():
|
def json_tables():
|
||||||
print('[migration] unpack dump/discours/*.bson to migration/data/*.json')
|
print('[migration] unpack dump/discours/*.bson to migration/data/*.json')
|
||||||
|
|
|
@ -3,8 +3,8 @@ from datetime import datetime
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import frontmatter
|
import frontmatter
|
||||||
from extract import extract_html, prepare_html_body
|
from .extract import extract_html, prepare_html_body
|
||||||
from utils import DateTimeEncoder
|
from .utils import DateTimeEncoder
|
||||||
|
|
||||||
OLD_DATE = '2016-03-05 22:22:00.350000'
|
OLD_DATE = '2016-03-05 22:22:00.350000'
|
||||||
EXPORT_DEST = '../discoursio-web/data/'
|
EXPORT_DEST = '../discoursio-web/data/'
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import base64
|
import base64
|
||||||
from html2text import html2text
|
from .html2text import html2text
|
||||||
|
|
||||||
TOOLTIP_REGEX = r'(\/\/\/(.+)\/\/\/)'
|
TOOLTIP_REGEX = r'(\/\/\/(.+)\/\/\/)'
|
||||||
contentDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'discoursio-web', 'content')
|
contentDir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..', '..', 'discoursio-web', 'content')
|
||||||
|
|
|
@ -3,7 +3,7 @@ from dateutil.parser import parse as date_parse
|
||||||
from orm import Reaction, User
|
from orm import Reaction, User
|
||||||
from orm import reaction
|
from orm import reaction
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
from html2text import html2text
|
from migration.html2text import html2text
|
||||||
from orm.reaction import ReactionKind
|
from orm.reaction import ReactionKind
|
||||||
from orm.shout import Shout
|
from orm.shout import Shout
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ from services.stat.viewed import ViewedByDay
|
||||||
from transliterate import translit
|
from transliterate import translit
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
from extract import prepare_html_body
|
from migration.extract import prepare_html_body
|
||||||
from orm.community import Community
|
from orm.community import Community
|
||||||
from orm.reaction import Reaction, ReactionKind
|
from orm.reaction import Reaction, ReactionKind
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from extract import extract_md, html2text
|
from migration.extract import extract_md, html2text
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
from orm import Topic, Community
|
from orm import Topic, Community
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from html2text import html2text
|
from migration.html2text import html2text
|
||||||
from orm import User, UserRating
|
from orm import User, UserRating
|
||||||
from dateutil.parser import parse
|
from dateutil.parser import parse
|
||||||
from base.orm import local_session
|
from base.orm import local_session
|
||||||
|
|
|
@ -4,9 +4,8 @@ from settings import PORT
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
dev_mode = len(sys.argv) > 1 and sys.argv[1] == "dev"
|
x = sys.argv[1] or ""
|
||||||
inbox_service = len(sys.argv) > 1 and sys.argv[1] == "inbox"
|
if x == "dev":
|
||||||
if dev_mode:
|
|
||||||
print("DEV MODE")
|
print("DEV MODE")
|
||||||
headers = [
|
headers = [
|
||||||
("Access-Control-Allow-Methods", "GET, POST, OPTIONS, HEAD"),
|
("Access-Control-Allow-Methods", "GET, POST, OPTIONS, HEAD"),
|
||||||
|
@ -16,5 +15,8 @@ if __name__ == '__main__':
|
||||||
("Access-Control-Allow-Credentials", "true")
|
("Access-Control-Allow-Credentials", "true")
|
||||||
]
|
]
|
||||||
uvicorn.run("main:app", host="localhost", port=8080, headers=headers) #, ssl_keyfile="discours.key", ssl_certfile="discours.crt", reload=True)
|
uvicorn.run("main:app", host="localhost", port=8080, headers=headers) #, ssl_keyfile="discours.key", ssl_certfile="discours.crt", reload=True)
|
||||||
|
elif x == "migrate":
|
||||||
|
from migration import migrate
|
||||||
|
migrate()
|
||||||
else:
|
else:
|
||||||
uvicorn.run("main:app", host="0.0.0.0", port=PORT)
|
uvicorn.run("main:app", host="0.0.0.0", port=PORT)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user