model-index-slug
All checks were successful
Deploy to core / deploy (push) Successful in 1m39s

This commit is contained in:
Untone 2024-02-19 13:25:47 +03:00
parent 8193bd0178
commit b89060f15f
6 changed files with 7 additions and 7 deletions

View File

@ -31,7 +31,7 @@ class Author(Base):
user = Column(String, unique=True) # unbounded link with authorizer's User type
name = Column(String, nullable=True, comment='Display name')
slug = Column(String, unique=True, comment="Author's slug")
slug = Column(String, unique=True, comment="Author's slug", index=True)
bio = Column(String, nullable=True, comment='Bio') # status description
about = Column(String, nullable=True, comment='About') # long and formatted
pic = Column(String, nullable=True, comment='Picture')

View File

@ -16,7 +16,7 @@ class ShoutCollection(Base):
class Collection(Base):
__tablename__ = 'collection'
slug = Column(String, unique=True)
slug = Column(String, unique=True, index=True)
title = Column(String, nullable=False, comment='Title')
body = Column(String, nullable=True, comment='Body')
pic = Column(String, nullable=True, comment='Picture')

View File

@ -21,7 +21,7 @@ class Community(Base):
__tablename__ = 'community'
name = Column(String, nullable=False)
slug = Column(String, nullable=False, unique=True)
slug = Column(String, nullable=False, unique=True, index=True)
desc = Column(String, nullable=False, default='')
pic = Column(String, nullable=False, default='')
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))

View File

@ -61,7 +61,7 @@ class Shout(Base):
deleted_by = Column(ForeignKey('author.id'), nullable=True)
body = Column(String, nullable=False, comment='Body')
slug = Column(String, unique=True)
slug = Column(String, unique=True, index=True)
cover = Column(String, nullable=True, comment='Cover image url')
cover_caption = Column(String, nullable=True, comment='Cover image alt caption')
lead = Column(String, nullable=True)

View File

@ -18,7 +18,7 @@ class TopicFollower(Base):
class Topic(Base):
__tablename__ = 'topic'
slug = Column(String, unique=True)
slug = Column(String, unique=True, index=True)
title = Column(String, nullable=False, comment='Title')
body = Column(String, nullable=True, comment='Body')
pic = Column(String, nullable=True, comment='Picture')

View File

@ -33,12 +33,12 @@ Base = declarative_base()
@event.listens_for(Engine, 'before_cursor_execute')
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
conn.info.setdefault('query_start_time', []).append(time.time())
logger.debug(f" {statement}")
logger.debug(f"\n{statement}")
@event.listens_for(Engine, 'after_cursor_execute')
def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
total = time.time() - conn.info['query_start_time'].pop(-1)
logger.debug(f' ... {total*1000} s ')
logger.debug(f' ... {total*1000} s\n')
def local_session(src=''):
return Session(bind=engine, expire_on_commit=False)