imports-format+id-fix+remigrate
This commit is contained in:
parent
b62211e05f
commit
503d6daa93
|
@ -10,7 +10,8 @@ import bs4
|
|||
|
||||
from migration.tables.comments import migrate as migrateComment
|
||||
from migration.tables.comments import migrate_2stage as migrateComment_2stage
|
||||
from migration.tables.content_items import get_shout_slug, migrate as migrateShout
|
||||
from migration.tables.content_items import get_shout_slug
|
||||
from migration.tables.content_items import migrate as migrateShout
|
||||
from migration.tables.topics import migrate as migrateTopic
|
||||
from migration.tables.users import migrate as migrateUser
|
||||
from migration.tables.users import migrate_2stage as migrateUser_2stage
|
||||
|
|
|
@ -2,6 +2,7 @@ import base64
|
|||
import os
|
||||
import re
|
||||
import uuid
|
||||
|
||||
from .html2text import html2text
|
||||
|
||||
TOOLTIP_REGEX = r"(\/\/\/(.+)\/\/\/)"
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
"antifashizm": "anti-faschism",
|
||||
"antiquity": "antiquity",
|
||||
"antiutopiya": "dystopia",
|
||||
"anton-dolin": "anton-dolin",
|
||||
"antropology": "antropology",
|
||||
"antropotsen": "antropocenus",
|
||||
"architecture": "architecture",
|
||||
|
@ -159,6 +160,7 @@
|
|||
"design": "design",
|
||||
"detskie-doma": "orphanages",
|
||||
"detstvo": "childhood",
|
||||
"devid-linch": "david-linch",
|
||||
"devyanostye": "90s",
|
||||
"dialog": "dialogue",
|
||||
"digital": "digital",
|
||||
|
@ -359,6 +361,7 @@
|
|||
"kazan": "kazan",
|
||||
"kiberbezopasnost": "cybersecurity",
|
||||
"kinoklub": "cinema-club",
|
||||
"kinokritika": "film-criticism",
|
||||
"kirill-serebrennikov": "kirill-serebrennikov",
|
||||
"kladbische": "cemetery",
|
||||
"klassika": "classic",
|
||||
|
@ -503,6 +506,7 @@
|
|||
"odinochestvo": "loneliness",
|
||||
"odna-kniga-odna-istoriya": "one-book-one-story",
|
||||
"okrainy": "outskirts",
|
||||
"omon": "swat",
|
||||
"opinions": "opinions",
|
||||
"oppozitsiya": "opposition",
|
||||
"orhan-pamuk": "orhan-pamuk",
|
||||
|
@ -779,6 +783,7 @@
|
|||
"vladimir-putin": "vladimir-putin",
|
||||
"vladimir-sorokin": "vladimir-sorokin",
|
||||
"vladimir-voynovich": "vladimir-voynovich",
|
||||
"vnutrenniy-opyt": "inner-expirience",
|
||||
"volga": "volga",
|
||||
"volontery": "volonteurs",
|
||||
"vong-karvay": "wong-karwai",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, String, ForeignKey, DateTime
|
||||
from sqlalchemy import Column, DateTime, ForeignKey, String
|
||||
|
||||
from base.orm import Base
|
||||
|
||||
|
@ -16,8 +16,7 @@ class ShoutCollection(Base):
|
|||
class Collection(Base):
|
||||
__tablename__ = "collection"
|
||||
|
||||
id = None # type: ignore
|
||||
slug = Column(String, primary_key=True)
|
||||
slug = Column(String, unique=True)
|
||||
title = Column(String, nullable=False, comment="Title")
|
||||
body = Column(String, nullable=True, comment="Body")
|
||||
pic = Column(String, nullable=True, comment="Picture")
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, Integer, String, ForeignKey, DateTime, Boolean
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from base.orm import Base
|
||||
|
@ -50,8 +50,7 @@ class ShoutAllowed(Base):
|
|||
class Shout(Base):
|
||||
__tablename__ = "shout"
|
||||
|
||||
id = None # type: ignore
|
||||
slug = Column(String, primary_key=True)
|
||||
slug = Column(String, unique=True)
|
||||
community = Column(Integer, ForeignKey("community.id"), nullable=False, comment="Community")
|
||||
lang = Column(String, nullable=False, default='ru', comment="Language")
|
||||
body = Column(String, nullable=False, comment="Body")
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Column, Boolean, String, ForeignKey, DateTime, JSON as JSONType
|
||||
from sqlalchemy import JSON as JSONType
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, String
|
||||
|
||||
from base.orm import Base
|
||||
|
||||
|
@ -20,8 +21,7 @@ class TopicFollower(Base):
|
|||
class Topic(Base):
|
||||
__tablename__ = "topic"
|
||||
|
||||
id = None # type: ignore
|
||||
slug = Column(String, primary_key=True)
|
||||
slug = Column(String, unique=True)
|
||||
title = Column(String, nullable=False, comment="Title")
|
||||
body = Column(String, nullable=True, comment="Body")
|
||||
pic = Column(String, nullable=True, comment="Picture")
|
||||
|
|
11
orm/user.py
11
orm/user.py
|
@ -1,14 +1,7 @@
|
|||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import (
|
||||
Column,
|
||||
Integer,
|
||||
String,
|
||||
ForeignKey,
|
||||
Boolean,
|
||||
DateTime,
|
||||
JSON as JSONType,
|
||||
)
|
||||
from sqlalchemy import JSON as JSONType
|
||||
from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from base.orm import Base, local_session
|
||||
|
|
|
@ -1,27 +1,22 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
from urllib.parse import quote_plus
|
||||
from datetime import datetime
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
from graphql.type import GraphQLResolveInfo
|
||||
from transliterate import translit
|
||||
from starlette.responses import RedirectResponse
|
||||
from transliterate import translit
|
||||
|
||||
from auth.jwtcodec import JWTCodec
|
||||
from auth.tokenstorage import TokenStorage
|
||||
from auth.authenticate import login_required
|
||||
from auth.email import send_auth_email
|
||||
from auth.identity import Identity, Password
|
||||
from base.exceptions import (
|
||||
BaseHttpException,
|
||||
InvalidPassword,
|
||||
InvalidToken,
|
||||
ObjectNotExist,
|
||||
OperationNotAllowed,
|
||||
)
|
||||
from auth.jwtcodec import JWTCodec
|
||||
from auth.tokenstorage import TokenStorage
|
||||
from base.exceptions import (BaseHttpException, InvalidPassword, InvalidToken,
|
||||
ObjectNotExist, OperationNotAllowed)
|
||||
from base.orm import local_session
|
||||
from base.resolvers import mutation, query
|
||||
from orm import User, Role
|
||||
from orm import Role, User
|
||||
from resolvers.profile import user_subscriptions
|
||||
|
||||
|
||||
|
|
|
@ -45,6 +45,7 @@ async def user_unpublished_shouts(_, info, offset, limit) -> List[Shout]:
|
|||
.join(ShoutAuthor)
|
||||
.where(and_(Shout.publishedAt.is_(None), ShoutAuthor.user == user.slug))
|
||||
.order_by(desc(Shout.createdAt))
|
||||
.group_by(Shout.id)
|
||||
.limit(limit)
|
||||
.offset(offset)
|
||||
.all()
|
||||
|
|
|
@ -317,7 +317,7 @@ type UserNotification {
|
|||
|
||||
type User {
|
||||
id: Int!
|
||||
username: String! # to login, ex. email
|
||||
username: String! # to login, ex. email, phone
|
||||
createdAt: DateTime!
|
||||
lastSeen: DateTime
|
||||
slug: String!
|
||||
|
@ -383,6 +383,7 @@ type Reaction {
|
|||
}
|
||||
|
||||
type Author {
|
||||
id: Int!
|
||||
slug: String!
|
||||
name: String!
|
||||
userpic: String
|
||||
|
@ -427,6 +428,7 @@ type Stat {
|
|||
}
|
||||
|
||||
type Community {
|
||||
id: Int!
|
||||
slug: String!
|
||||
name: String!
|
||||
desc: String
|
||||
|
@ -436,6 +438,7 @@ type Community {
|
|||
}
|
||||
|
||||
type Collection {
|
||||
id: Int!
|
||||
slug: String!
|
||||
title: String!
|
||||
desc: String
|
||||
|
|
|
@ -58,6 +58,7 @@ class ShoutsCache:
|
|||
)
|
||||
.where(Shout.deletedAt.is_(None))
|
||||
.filter(Shout.publishedAt.is_not(None))
|
||||
.group_by(Shout.id)
|
||||
.order_by(desc("publishedAt"))
|
||||
# .limit(ShoutsCache.limit)
|
||||
),
|
||||
|
@ -87,6 +88,7 @@ class ShoutsCache:
|
|||
selectinload(Shout.topics)
|
||||
)
|
||||
.where(Shout.deletedAt.is_(None))
|
||||
.group_by(Shout.id)
|
||||
.order_by(desc("createdAt"))
|
||||
# .limit(ShoutsCache.limit)
|
||||
)
|
||||
|
@ -118,7 +120,7 @@ class ShoutsCache:
|
|||
.join(Reaction)
|
||||
.where(and_(Shout.deletedAt.is_(None), Shout.slug.in_(reacted_slugs)))
|
||||
.filter(Shout.publishedAt.is_not(None))
|
||||
.group_by(Shout.slug, "reactedAt")
|
||||
.group_by(Shout.id, "reactedAt")
|
||||
.order_by(desc("reactedAt"))
|
||||
# .limit(ShoutsCache.limit)
|
||||
)
|
||||
|
@ -150,7 +152,7 @@ class ShoutsCache:
|
|||
)
|
||||
.join(Reaction)
|
||||
.where(and_(Shout.deletedAt.is_(None), Shout.slug.in_(commented_slugs)))
|
||||
.group_by(Shout.slug, "reactedAt")
|
||||
.group_by(Shout.id, "reactedAt")
|
||||
.order_by(desc("reactedAt"))
|
||||
# .limit(ShoutsCache.limit)
|
||||
)
|
||||
|
@ -177,7 +179,7 @@ class ShoutsCache:
|
|||
.join(Reaction, Reaction.kind == ReactionKind.LIKE)
|
||||
.where(Shout.deletedAt.is_(None))
|
||||
.filter(Shout.publishedAt.is_not(None))
|
||||
.group_by(Shout.slug)
|
||||
.group_by(Shout.id)
|
||||
.order_by(desc("reacted"))
|
||||
# .limit(ShoutsCache.limit)
|
||||
),
|
||||
|
@ -203,7 +205,7 @@ class ShoutsCache:
|
|||
.join(Reaction)
|
||||
.where(Shout.deletedAt.is_(None))
|
||||
.filter(Shout.publishedAt > month_ago)
|
||||
.group_by(Shout.slug)
|
||||
.group_by(Shout.id)
|
||||
# .limit(ShoutsCache.limit)
|
||||
),
|
||||
)
|
||||
|
@ -231,7 +233,7 @@ class ShoutsCache:
|
|||
.join(Reaction, func.length(Reaction.body) > 0)
|
||||
.where(Shout.deletedAt.is_(None))
|
||||
.filter(Shout.publishedAt > month_ago)
|
||||
.group_by(Shout.slug)
|
||||
.group_by(Shout.id)
|
||||
.order_by(desc("commented"))
|
||||
# .limit(ShoutsCache.limit)
|
||||
),
|
||||
|
|
Loading…
Reference in New Issue
Block a user