diff --git a/migration/__init__.py b/migration/__init__.py index 670c81eb..edc2f6b4 100644 --- a/migration/__init__.py +++ b/migration/__init__.py @@ -301,4 +301,4 @@ def migrate(): print('[migration] usage: python migrate.py ') print('[migration] commands: mongodb, bson, all, all mdx, - ') -migrate() +if __name__ == '__main__': migrate() diff --git a/migration/tables/content_items.py b/migration/tables/content_items.py index 849df0bb..5db08b34 100644 --- a/migration/tables/content_items.py +++ b/migration/tables/content_items.py @@ -89,7 +89,6 @@ def migrate(entry, storage): r['updatedAt'] = date_parse(entry['updatedAt']) if 'updatedAt' in entry else ts if entry.get('published'): r['publishedAt'] = date_parse(entry.get('publishedAt', OLD_DATE)) - if r['publishedAt'] == OLD_DATE: r['publishedAt'] = ts if 'deletedAt' in entry: r['deletedAt'] = date_parse(entry['deletedAt']) # topics diff --git a/orm/user.py b/orm/user.py index e7947b0d..c6449d9b 100644 --- a/orm/user.py +++ b/orm/user.py @@ -67,6 +67,7 @@ class User(Base): id = 0, email = "welcome@discours.io", username = "welcome@discours.io", + name = "Дискурс", slug = "discours", userpic = 'https://discours.io/images/logo-mini.svg', ) diff --git a/services/zine/shoutscache.py b/services/zine/shoutscache.py index c1e57a06..56fb1adc 100644 --- a/services/zine/shoutscache.py +++ b/services/zine/shoutscache.py @@ -2,10 +2,11 @@ import asyncio from datetime import datetime, timedelta from sqlalchemy import and_, desc, func, select -from sqlalchemy.orm import selectinload +from sqlalchemy.orm import selectinload, joinedload from base.orm import local_session from orm.reaction import Reaction from orm.shout import Shout +from orm.topic import Topic from services.zine.reactions import ReactionsStorage from services.stat.viewed import ViewedByDay @@ -36,12 +37,16 @@ class ShoutsCache: async def prepare_recent_all(): with local_session() as session: stmt = select(Shout).\ - options(selectinload(Shout.authors), selectinload(Shout.topics)).\ + options( + selectinload(Shout.authors), + selectinload(Shout.topics) + ).\ order_by(desc("createdAt")).\ limit(ShoutsCache.limit) shouts = [] for row in session.execute(stmt): shout = row.Shout + # shout.topics = [t.slug for t in shout.topics] shout.rating = await ReactionsStorage.shout_rating(shout.slug) or 0 shouts.append(shout) async with ShoutsCache.lock: @@ -64,6 +69,7 @@ class ShoutsCache: shouts = [] for row in session.execute(stmt): shout = row.Shout + # shout.topics = [t.slug for t in shout.topics] shout.rating = await ReactionsStorage.shout_rating(shout.slug) or 0 shouts.append(shout) async with ShoutsCache.lock: