mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 00:46:03 +00:00
topic: Move sqlalchemy methods into their own file.
Loading sqlalchemy can take a significant amount of time, so splitting these into these own file can be a significant startup-time savings.
This commit is contained in:
committed by
Tim Abbott
parent
1abd356a91
commit
57ff573535
20
zerver/lib/topic_sqlalchemy.py
Normal file
20
zerver/lib/topic_sqlalchemy.py
Normal file
@@ -0,0 +1,20 @@
|
||||
from sqlalchemy.sql import ColumnElement, column, func, literal
|
||||
from sqlalchemy.types import Boolean, Text
|
||||
|
||||
from zerver.lib.topic import RESOLVED_TOPIC_PREFIX
|
||||
|
||||
|
||||
def topic_match_sa(topic_name: str) -> ColumnElement[Boolean]:
|
||||
# _sa is short for SQLAlchemy, which we use mostly for
|
||||
# queries that search messages
|
||||
topic_cond = func.upper(column("subject", Text)) == func.upper(literal(topic_name))
|
||||
return topic_cond
|
||||
|
||||
|
||||
def get_resolved_topic_condition_sa() -> ColumnElement[Boolean]:
|
||||
resolved_topic_cond = column("subject", Text).startswith(RESOLVED_TOPIC_PREFIX)
|
||||
return resolved_topic_cond
|
||||
|
||||
|
||||
def topic_column_sa() -> ColumnElement[Text]:
|
||||
return column("subject", Text)
|
||||
Reference in New Issue
Block a user