This commit is contained in:
parent
8193bd0178
commit
b89060f15f
|
@ -31,7 +31,7 @@ class Author(Base):
|
||||||
user = Column(String, unique=True) # unbounded link with authorizer's User type
|
user = Column(String, unique=True) # unbounded link with authorizer's User type
|
||||||
|
|
||||||
name = Column(String, nullable=True, comment='Display name')
|
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
|
bio = Column(String, nullable=True, comment='Bio') # status description
|
||||||
about = Column(String, nullable=True, comment='About') # long and formatted
|
about = Column(String, nullable=True, comment='About') # long and formatted
|
||||||
pic = Column(String, nullable=True, comment='Picture')
|
pic = Column(String, nullable=True, comment='Picture')
|
||||||
|
|
|
@ -16,7 +16,7 @@ class ShoutCollection(Base):
|
||||||
class Collection(Base):
|
class Collection(Base):
|
||||||
__tablename__ = 'collection'
|
__tablename__ = 'collection'
|
||||||
|
|
||||||
slug = Column(String, unique=True)
|
slug = Column(String, unique=True, index=True)
|
||||||
title = Column(String, nullable=False, comment='Title')
|
title = Column(String, nullable=False, comment='Title')
|
||||||
body = Column(String, nullable=True, comment='Body')
|
body = Column(String, nullable=True, comment='Body')
|
||||||
pic = Column(String, nullable=True, comment='Picture')
|
pic = Column(String, nullable=True, comment='Picture')
|
||||||
|
|
|
@ -21,7 +21,7 @@ class Community(Base):
|
||||||
__tablename__ = 'community'
|
__tablename__ = 'community'
|
||||||
|
|
||||||
name = Column(String, nullable=False)
|
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='')
|
desc = Column(String, nullable=False, default='')
|
||||||
pic = Column(String, nullable=False, default='')
|
pic = Column(String, nullable=False, default='')
|
||||||
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
|
created_at = Column(Integer, nullable=False, default=lambda: int(time.time()))
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Shout(Base):
|
||||||
deleted_by = Column(ForeignKey('author.id'), nullable=True)
|
deleted_by = Column(ForeignKey('author.id'), nullable=True)
|
||||||
|
|
||||||
body = Column(String, nullable=False, comment='Body')
|
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 = Column(String, nullable=True, comment='Cover image url')
|
||||||
cover_caption = Column(String, nullable=True, comment='Cover image alt caption')
|
cover_caption = Column(String, nullable=True, comment='Cover image alt caption')
|
||||||
lead = Column(String, nullable=True)
|
lead = Column(String, nullable=True)
|
||||||
|
|
|
@ -18,7 +18,7 @@ class TopicFollower(Base):
|
||||||
class Topic(Base):
|
class Topic(Base):
|
||||||
__tablename__ = 'topic'
|
__tablename__ = 'topic'
|
||||||
|
|
||||||
slug = Column(String, unique=True)
|
slug = Column(String, unique=True, index=True)
|
||||||
title = Column(String, nullable=False, comment='Title')
|
title = Column(String, nullable=False, comment='Title')
|
||||||
body = Column(String, nullable=True, comment='Body')
|
body = Column(String, nullable=True, comment='Body')
|
||||||
pic = Column(String, nullable=True, comment='Picture')
|
pic = Column(String, nullable=True, comment='Picture')
|
||||||
|
|
|
@ -33,12 +33,12 @@ Base = declarative_base()
|
||||||
@event.listens_for(Engine, 'before_cursor_execute')
|
@event.listens_for(Engine, 'before_cursor_execute')
|
||||||
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
def before_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
||||||
conn.info.setdefault('query_start_time', []).append(time.time())
|
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')
|
@event.listens_for(Engine, 'after_cursor_execute')
|
||||||
def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
def after_cursor_execute(conn, cursor, statement, parameters, context, executemany):
|
||||||
total = time.time() - conn.info['query_start_time'].pop(-1)
|
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=''):
|
def local_session(src=''):
|
||||||
return Session(bind=engine, expire_on_commit=False)
|
return Session(bind=engine, expire_on_commit=False)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user