This commit is contained in:
parent
306caf9520
commit
5fe51e03bb
|
@ -1,4 +1,4 @@
|
|||
from sqlalchemy import and_, distinct, func, join, select
|
||||
from sqlalchemy import and_, distinct, func, join, select, CompoundSelect
|
||||
from sqlalchemy.orm import aliased
|
||||
|
||||
from orm.author import Author, AuthorFollower
|
||||
|
@ -180,16 +180,17 @@ def get_author_comments_stat(author_id: int):
|
|||
def get_with_stat(q):
|
||||
records = []
|
||||
try:
|
||||
is_author = f"{q}".lower().startswith("select author")
|
||||
# is_topic = f"{q}".lower().startswith("select topic")
|
||||
result = []
|
||||
if is_author:
|
||||
q = add_author_stat_columns(q)
|
||||
else:
|
||||
q = add_topic_stat_columns(q)
|
||||
with local_session() as session:
|
||||
result = session.execute(q)
|
||||
# Convert the CompoundSelect object to a Query object
|
||||
if isinstance(q, CompoundSelect):
|
||||
q = session.query().from_statement(q)
|
||||
|
||||
# detect author
|
||||
is_author = f"{q}".lower().startswith("select author")
|
||||
q = add_author_stat_columns(q) if is_author else add_topic_stat_columns(q)
|
||||
|
||||
# execute query
|
||||
result = session.execute(q)
|
||||
for cols in result:
|
||||
entity = cols[0]
|
||||
stat = dict()
|
||||
|
|
|
@ -138,13 +138,17 @@ class SearchService:
|
|||
result = json.loads(result)
|
||||
if isinstance(result, dict):
|
||||
mapping = result.get(self.index_name, {}).get("mappings")
|
||||
logger.debug(f"Найдена структура индексации: {mapping['properties'].keys()}")
|
||||
logger.debug(
|
||||
f"Найдена структура индексации: {mapping['properties'].keys()}"
|
||||
)
|
||||
if (
|
||||
mapping
|
||||
and mapping["properties"].keys()
|
||||
!= expected_mapping["properties"].keys()
|
||||
):
|
||||
logger.debug(f"Ожидаемая структура индексации: {expected_mapping}")
|
||||
logger.debug(
|
||||
f"Ожидаемая структура индексации: {expected_mapping}"
|
||||
)
|
||||
logger.warn("[!!!] Требуется переиндексация всех данных")
|
||||
self.delete_index()
|
||||
self.client = None
|
||||
|
|
Loading…
Reference in New Issue
Block a user