diff --git a/resolvers/auth.py b/resolvers/auth.py index 08bf22ea..ff565dfb 100644 --- a/resolvers/auth.py +++ b/resolvers/auth.py @@ -72,11 +72,11 @@ async def confirm_email_handler(request): token = request.path_params["token"] # one time request.session["token"] = token res = await confirm_email(None, {}, token) - # print('[resolvers.auth] confirm_email response: %r' % res) + print('[resolvers.auth] confirm_email request: %r' % request) if "error" in res: raise BaseHttpException(res['error']) else: - response = RedirectResponse(url="https://new.discours.io/confirm") + response = RedirectResponse(url="https://new.discours.io") response.set_cookie("token", res["token"]) # session token return response diff --git a/resolvers/profile.py b/resolvers/profile.py index b8ade3fd..a20243f6 100644 --- a/resolvers/profile.py +++ b/resolvers/profile.py @@ -23,7 +23,7 @@ async def user_subscriptions(slug: str): "unread": await get_unread_counter(slug), # unread inbox messages counter "topics": [t.slug for t in await followed_topics(slug)], # followed topics slugs "authors": [a.slug for a in await followed_authors(slug)], # followed authors slugs - "reactions": len(await ReactedStorage.get_shout(slug)), + "reactions": await ReactedStorage.get_shouts_by_author(slug), "communities": [c.slug for c in followed_communities(slug)], # communities } diff --git a/schema.graphql b/schema.graphql index 62800219..06296c03 100644 --- a/schema.graphql +++ b/schema.graphql @@ -156,7 +156,7 @@ type Mutation { refreshSession: AuthResult! registerUser(email: String!, password: String, name: String): AuthResult! sendLink(email: String!, lang: String): Result! - confirmEmail(code: String!): AuthResult! + confirmEmail(token: String!): AuthResult! # shout createShout(input: ShoutInput!): Result! diff --git a/services/stat/reacted.py b/services/stat/reacted.py index cb5a8be9..f144fe9c 100644 --- a/services/stat/reacted.py +++ b/services/stat/reacted.py @@ -24,7 +24,7 @@ def kind_to_rate(kind) -> int: class ReactedStorage: - reacted = {"shouts": {}, "topics": {}, "reactions": {}} + reacted = {"shouts": {}, "topics": {}, "reactions": {}, "authors": {}} rating = {"shouts": {}, "topics": {}, "reactions": {}} reactions = [] to_flush = [] @@ -38,6 +38,23 @@ class ReactedStorage: async with self.lock: return self.reacted["shouts"].get(shout_slug, []) + @staticmethod + async def get_author(user_slug): + self = ReactedStorage + async with self.lock: + return self.reacted["authors"].get(user_slug, []) + + @staticmethod + async def get_shouts_by_author(user_slug): + self = ReactedStorage + async with self.lock: + author_reactions = self.reacted["authors"].get(user_slug, []) + shouts = [] + for r in author_reactions: + if r.shout not in shouts: + shouts.append(r.shout) + return shouts + @staticmethod async def get_topic(topic_slug): self = ReactedStorage @@ -111,10 +128,13 @@ class ReactedStorage: async def recount(reactions): self = ReactedStorage for r in reactions: - # renew shout counters + # renew reactions by shout self.reacted["shouts"][r.shout] = self.reacted["shouts"].get(r.shout, []) self.reacted["shouts"][r.shout].append(r) - # renew topics counters + # renew reactions by author + self.reacted["authors"][r.createdBy] = self.reacted["authors"].get(r.createdBy, []) + self.reacted["authors"][r.createdBy].append(r) + # renew reactions by topic shout_topics = await TopicStorage.get_topics_by_slugs([r.shout, ]) for t in shout_topics: self.reacted["topics"][t] = self.reacted["topics"].get(t, []) @@ -122,7 +142,7 @@ class ReactedStorage: self.rating["topics"][t] = \ self.rating["topics"].get(t, 0) + kind_to_rate(r.kind) if r.replyTo: - # renew reaction counters + # renew reactions replies self.reacted["reactions"][r.replyTo] = \ self.reacted["reactions"].get(r.replyTo, []) self.reacted["reactions"][r.replyTo].append(r)