followers-migrated
This commit is contained in:
@@ -93,7 +93,10 @@ async def get_communities(_, info):
|
||||
|
||||
|
||||
def community_follow(user, slug):
|
||||
CommunityFollower.create(follower=user.slug, community=slug)
|
||||
with local_session() as session:
|
||||
cf = CommunityFollower.create(follower=user.slug, community=slug)
|
||||
session.add(cf)
|
||||
session.commit()
|
||||
|
||||
|
||||
def community_unfollow(user, slug):
|
||||
|
@@ -165,7 +165,10 @@ async def rate_user(_, info, slug, value):
|
||||
|
||||
# for mutation.field("follow")
|
||||
def author_follow(user, slug):
|
||||
AuthorFollower.create(follower=user.slug, author=slug)
|
||||
with local_session() as session:
|
||||
af = AuthorFollower.create(follower=user.slug, author=slug)
|
||||
session.add(af)
|
||||
session.commit()
|
||||
|
||||
|
||||
# for mutation.field("unfollow")
|
||||
|
@@ -14,25 +14,22 @@ from services.stat.reacted import ReactedStorage
|
||||
|
||||
def reactions_follow(user, slug, auto=False):
|
||||
with local_session() as session:
|
||||
fw = (
|
||||
following = (
|
||||
session.query(ShoutReactionsFollower)
|
||||
.filter(
|
||||
ShoutReactionsFollower.follower == user.slug,
|
||||
ShoutReactionsFollower.shout == slug,
|
||||
ShoutReactionsFollower.shout == slug
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if auto and fw:
|
||||
return
|
||||
elif not auto and fw:
|
||||
if bool(fw.deletedAt):
|
||||
fw.deletedAt = None
|
||||
fw.auto = False
|
||||
session.commit()
|
||||
return
|
||||
# print("[resolvers.reactions] was followed before")
|
||||
|
||||
ShoutReactionsFollower.create(follower=user.slug, shout=slug, auto=auto)
|
||||
if not following:
|
||||
following = ShoutReactionsFollower.create(
|
||||
follower=user.slug,
|
||||
shout=slug,
|
||||
auto=auto
|
||||
)
|
||||
session.add(following)
|
||||
session.commit()
|
||||
|
||||
|
||||
def reactions_unfollow(user, slug):
|
||||
@@ -45,14 +42,9 @@ def reactions_unfollow(user, slug):
|
||||
)
|
||||
.first()
|
||||
)
|
||||
if not following:
|
||||
# print("[resolvers.reactions] was not followed", slug)
|
||||
return
|
||||
if following.auto:
|
||||
following.deletedAt = datetime.now()
|
||||
else:
|
||||
if following:
|
||||
session.delete(following)
|
||||
session.commit()
|
||||
session.commit()
|
||||
|
||||
|
||||
@mutation.field("createReaction")
|
||||
|
@@ -50,20 +50,23 @@ async def create_topic(_, _info, inp):
|
||||
@login_required
|
||||
async def update_topic(_, _info, inp):
|
||||
slug = inp["slug"]
|
||||
session = local_session()
|
||||
topic = session.query(Topic).filter(Topic.slug == slug).first()
|
||||
if not topic:
|
||||
return {"error": "topic not found"}
|
||||
topic.update(**inp)
|
||||
session.commit()
|
||||
session.close()
|
||||
await TopicStorage.update_topic(topic.slug)
|
||||
return {"topic": topic}
|
||||
with local_session() as session:
|
||||
topic = session.query(Topic).filter(Topic.slug == slug).first()
|
||||
if not topic:
|
||||
return {"error": "topic not found"}
|
||||
else:
|
||||
topic.update(**inp)
|
||||
session.commit()
|
||||
await TopicStorage.update_topic(topic.slug)
|
||||
return {"topic": topic}
|
||||
|
||||
|
||||
async def topic_follow(user, slug):
|
||||
TopicFollower.create(topic=slug, follower=user.slug)
|
||||
await TopicStorage.update_topic(slug)
|
||||
with local_session() as session:
|
||||
following = TopicFollower.create(topic=slug, follower=user.slug)
|
||||
session.add(following)
|
||||
session.commit()
|
||||
await TopicStorage.update_topic(slug)
|
||||
|
||||
|
||||
async def topic_unfollow(user, slug):
|
||||
|
@@ -112,7 +112,7 @@ async def get_search_results(_, _info, query, offset, limit):
|
||||
for s in shouts:
|
||||
for a in s.authors:
|
||||
a.caption = await ShoutAuthorStorage.get_author_caption(s.slug, a.slug)
|
||||
s.stat.relevance = 1 # FIXME
|
||||
s.stat.relevance = 1 # FIXME: expecting search engine rated relevance
|
||||
return shouts
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user