This commit is contained in:
parent
3d90d9c81d
commit
a749ade30b
|
@ -7,7 +7,6 @@ from services.db import Base
|
|||
# from sqlalchemy_utils import TSVectorType
|
||||
|
||||
|
||||
|
||||
class AuthorRating(Base):
|
||||
__tablename__ = "author_rating"
|
||||
|
||||
|
|
|
@ -11,7 +11,12 @@ from resolvers.author import ( # search_authors,
|
|||
)
|
||||
from resolvers.community import get_communities_all, get_community
|
||||
from resolvers.editor import create_shout, delete_shout, update_shout
|
||||
from resolvers.follower import follow, get_shout_followers, get_topic_followers, unfollow
|
||||
from resolvers.follower import (
|
||||
follow,
|
||||
get_shout_followers,
|
||||
get_topic_followers,
|
||||
unfollow,
|
||||
)
|
||||
from resolvers.notifier import (
|
||||
load_notifications,
|
||||
notification_mark_seen,
|
||||
|
@ -35,7 +40,12 @@ from resolvers.reader import (
|
|||
load_shouts_search,
|
||||
load_shouts_unrated,
|
||||
)
|
||||
from resolvers.topic import get_topic, get_topics_all, get_topics_by_author, get_topics_by_community
|
||||
from resolvers.topic import (
|
||||
get_topic,
|
||||
get_topics_all,
|
||||
get_topics_by_author,
|
||||
get_topics_by_community,
|
||||
)
|
||||
from services.triggers import events_register
|
||||
|
||||
events_register()
|
||||
|
|
|
@ -8,7 +8,12 @@ from sqlalchemy.orm import aliased
|
|||
from sqlalchemy.sql import not_
|
||||
|
||||
from orm.author import Author
|
||||
from orm.notification import Notification, NotificationAction, NotificationEntity, NotificationSeen
|
||||
from orm.notification import (
|
||||
Notification,
|
||||
NotificationAction,
|
||||
NotificationEntity,
|
||||
NotificationSeen,
|
||||
)
|
||||
from orm.shout import Shout
|
||||
from services.auth import login_required
|
||||
from services.db import local_session
|
||||
|
|
|
@ -31,9 +31,7 @@ def add_author_stat_columns(q):
|
|||
func.count(distinct(aliased_shout.shout)).label("shouts_stat")
|
||||
)
|
||||
aliased_follower = aliased(AuthorFollower)
|
||||
q = q.outerjoin(
|
||||
aliased_follower, aliased_follower.author == Author.id
|
||||
).add_columns(
|
||||
q = q.outerjoin(aliased_follower, aliased_follower.author == Author.id).add_columns(
|
||||
func.count(distinct(aliased_follower.follower)).label("followers_stat")
|
||||
)
|
||||
|
||||
|
|
|
@ -12,7 +12,10 @@ ELASTIC_HOST = os.environ.get("ELASTIC_HOST", "").replace("https://", "")
|
|||
ELASTIC_USER = os.environ.get("ELASTIC_USER", "")
|
||||
ELASTIC_PASSWORD = os.environ.get("ELASTIC_PASSWORD", "")
|
||||
ELASTIC_PORT = os.environ.get("ELASTIC_PORT", 9200)
|
||||
ELASTIC_URL = os.environ.get("ELASTIC_URL", f"https://{ELASTIC_USER}:{ELASTIC_PASSWORD}@{ELASTIC_HOST}:{ELASTIC_PORT}")
|
||||
ELASTIC_URL = os.environ.get(
|
||||
"ELASTIC_URL",
|
||||
f"https://{ELASTIC_USER}:{ELASTIC_PASSWORD}@{ELASTIC_HOST}:{ELASTIC_PORT}",
|
||||
)
|
||||
REDIS_TTL = 86400 # 1 день в секундах
|
||||
|
||||
index_settings = {
|
||||
|
@ -113,7 +116,9 @@ class SearchService:
|
|||
mapping = result.get(self.index_name, {}).get("mappings")
|
||||
if mapping and mapping != expected_mapping:
|
||||
logger.debug(f"Найдена структура индексации: {mapping}")
|
||||
logger.warn("Требуется другая структура индексации, переиндексация")
|
||||
logger.warn(
|
||||
"Требуется другая структура индексации, переиндексация"
|
||||
)
|
||||
await self.recreate_index()
|
||||
else:
|
||||
logger.error("клиент не инициализован, невозможно проверить индекс")
|
||||
|
@ -121,7 +126,9 @@ class SearchService:
|
|||
async def recreate_index(self):
|
||||
if self.client:
|
||||
async with self.lock:
|
||||
self.client.indices.delete(index=self.index_name, ignore_unavailable=True)
|
||||
self.client.indices.delete(
|
||||
index=self.index_name, ignore_unavailable=True
|
||||
)
|
||||
await self.check_index()
|
||||
else:
|
||||
logger.error("клиент не инициализован, невозможно пересоздать индекс")
|
||||
|
@ -136,7 +143,9 @@ class SearchService:
|
|||
|
||||
async def perform_index(self, shout):
|
||||
if self.client:
|
||||
self.client.index(index=self.index_name, id=str(shout.id), body=shout.dict())
|
||||
self.client.index(
|
||||
index=self.index_name, id=str(shout.id), body=shout.dict()
|
||||
)
|
||||
|
||||
async def search(self, text, limit, offset):
|
||||
logger.debug(f"Ищем: {text}")
|
||||
|
|
|
@ -7,7 +7,12 @@ from typing import Dict
|
|||
|
||||
# ga
|
||||
from google.analytics.data_v1beta import BetaAnalyticsDataClient
|
||||
from google.analytics.data_v1beta.types import DateRange, Dimension, Metric, RunReportRequest
|
||||
from google.analytics.data_v1beta.types import (
|
||||
DateRange,
|
||||
Dimension,
|
||||
Metric,
|
||||
RunReportRequest,
|
||||
)
|
||||
|
||||
from orm.author import Author
|
||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic
|
||||
|
|
Loading…
Reference in New Issue
Block a user