This commit is contained in:
parent
3379376016
commit
af5746c5d8
|
@ -10,9 +10,9 @@ from services.schema import mutation, query
|
||||||
from orm.shout import ShoutAuthor, ShoutTopic
|
from orm.shout import ShoutAuthor, ShoutTopic
|
||||||
from orm.topic import Topic
|
from orm.topic import Topic
|
||||||
from orm.author import AuthorFollower, Author, AuthorRating
|
from orm.author import AuthorFollower, Author, AuthorRating
|
||||||
from community import followed_communities
|
from resolvers.community import followed_communities
|
||||||
from topic import followed_topics
|
from resolvers.topic import followed_topics
|
||||||
from reaction import reacted_shouts_updates as followed_reactions
|
from resolvers.reaction import reacted_shouts_updates as followed_reactions
|
||||||
|
|
||||||
|
|
||||||
def add_author_stat_columns(q):
|
def add_author_stat_columns(q):
|
||||||
|
|
|
@ -6,7 +6,7 @@ from services.db import local_session
|
||||||
from services.schema import mutation, query
|
from services.schema import mutation, query
|
||||||
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility
|
from orm.shout import Shout, ShoutAuthor, ShoutTopic, ShoutVisibility
|
||||||
from orm.topic import Topic
|
from orm.topic import Topic
|
||||||
from reaction import reactions_follow, reactions_unfollow
|
from resolvers.reaction import reactions_follow, reactions_unfollow
|
||||||
from services.notify import notify_shout
|
from services.notify import notify_shout
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@ import asyncio
|
||||||
import json
|
import json
|
||||||
from services.rediscache import redis
|
from services.rediscache import redis
|
||||||
from orm.shout import Shout
|
from orm.shout import Shout
|
||||||
from resolvers.load import load_shouts_by
|
from resolvers.reader import load_shouts_by
|
||||||
|
|
||||||
|
|
||||||
class SearchService:
|
class SearchService:
|
||||||
|
|
|
@ -7,7 +7,7 @@ from gql import Client, gql
|
||||||
from gql.transport.httpx import HTTPXAsyncTransport
|
from gql.transport.httpx import HTTPXAsyncTransport
|
||||||
|
|
||||||
from services.db import local_session
|
from services.db import local_session
|
||||||
from orm import Topic
|
from orm.topic import Topic
|
||||||
from orm.shout import ShoutTopic, Shout
|
from orm.shout import ShoutTopic, Shout
|
||||||
|
|
||||||
load_facts = gql(
|
load_facts = gql(
|
||||||
|
@ -72,12 +72,8 @@ class ViewedStorage:
|
||||||
self = ViewedStorage
|
self = ViewedStorage
|
||||||
async with self.lock:
|
async with self.lock:
|
||||||
if token:
|
if token:
|
||||||
self.client = create_client(
|
self.client = create_client({"Authorization": "Bearer %s" % str(token)}, schema=schema_str)
|
||||||
{"Authorization": "Bearer %s" % str(token)}, schema=schema_str
|
print("[services.viewed] * authorized permanentely by ackee.discours.io: %s" % token)
|
||||||
)
|
|
||||||
print(
|
|
||||||
"[services.viewed] * authorized permanentely by ackee.discours.io: %s" % token
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
print("[services.viewed] * please set ACKEE_TOKEN")
|
print("[services.viewed] * please set ACKEE_TOKEN")
|
||||||
self.disabled = True
|
self.disabled = True
|
||||||
|
@ -144,11 +140,7 @@ class ViewedStorage:
|
||||||
self = ViewedStorage
|
self = ViewedStorage
|
||||||
with local_session() as session:
|
with local_session() as session:
|
||||||
for [shout_topic, topic] in (
|
for [shout_topic, topic] in (
|
||||||
session.query(ShoutTopic, Topic)
|
session.query(ShoutTopic, Topic).join(Topic).join(Shout).where(Shout.slug == shout_slug).all()
|
||||||
.join(Topic)
|
|
||||||
.join(Shout)
|
|
||||||
.where(Shout.slug == shout_slug)
|
|
||||||
.all()
|
|
||||||
):
|
):
|
||||||
if not self.by_topics.get(topic.slug):
|
if not self.by_topics.get(topic.slug):
|
||||||
self.by_topics[topic.slug] = {}
|
self.by_topics[topic.slug] = {}
|
||||||
|
@ -192,10 +184,7 @@ class ViewedStorage:
|
||||||
if failed == 0:
|
if failed == 0:
|
||||||
when = datetime.now(timezone.utc) + timedelta(seconds=self.period)
|
when = datetime.now(timezone.utc) + timedelta(seconds=self.period)
|
||||||
t = format(when.astimezone().isoformat())
|
t = format(when.astimezone().isoformat())
|
||||||
print(
|
print("[services.viewed] ⎩ next update: %s" % (t.split("T")[0] + " " + t.split("T")[1].split(".")[0]))
|
||||||
"[services.viewed] ⎩ next update: %s"
|
|
||||||
% (t.split("T")[0] + " " + t.split("T")[1].split(".")[0])
|
|
||||||
)
|
|
||||||
await asyncio.sleep(self.period)
|
await asyncio.sleep(self.period)
|
||||||
else:
|
else:
|
||||||
await asyncio.sleep(10)
|
await asyncio.sleep(10)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user