old naming

This commit is contained in:
2022-11-30 09:27:12 +03:00
parent 8209cc744c
commit 44bd4f6ede
18 changed files with 90 additions and 90 deletions

View File

@@ -73,7 +73,7 @@ async def migrate(entry, storage):
Shout
).where(Shout.slug == shout_dict["slug"]).one()
reaction_dict["shoutId"] = shout.id
reaction_dict["shout"] = shout.id
reaction_dict["createdBy"] = author.id if author else 1
reaction_dict["kind"] = ReactionKind.COMMENT
@@ -91,13 +91,13 @@ async def migrate(entry, storage):
).where(
User.id == reaction_dict["createdBy"]
).filter(
ShoutReactionsFollower.shoutId == reaction.shoutId
ShoutReactionsFollower.shout == reaction.shout
).first()
if not following1:
following1 = ShoutReactionsFollower.create(
followerId=reaction_dict["createdBy"],
shoutId=reaction.shoutId,
follower=reaction_dict["createdBy"],
shout=reaction.shout,
auto=True
)
session.add(following1)
@@ -109,7 +109,7 @@ async def migrate(entry, storage):
).join(
Topic
).where(
TopicFollower.followerId == reaction_dict["createdBy"]
TopicFollower.follower == reaction_dict["createdBy"]
).filter(
Topic.slug == t
).first()
@@ -120,8 +120,8 @@ async def migrate(entry, storage):
).where(Topic.slug == t).one()
topic_following = TopicFollower.create(
followerId=reaction_dict["createdBy"],
topicId=topic.id,
follower=reaction_dict["createdBy"],
topic=topic.id,
auto=True
)
session.add(topic_following)
@@ -134,7 +134,7 @@ async def migrate(entry, storage):
.first()
)
re_reaction_dict = {
"shoutId": reaction_dict["shoutId"],
"shout": reaction_dict["shout"],
"replyTo": reaction.id,
"kind": ReactionKind.LIKE
if comment_rating_old["value"] > 0
@@ -150,14 +150,14 @@ async def migrate(entry, storage):
following2 = session.query(
ShoutReactionsFollower
).where(
ShoutReactionsFollower.followerId == re_reaction_dict['createdBy']
ShoutReactionsFollower.follower == re_reaction_dict['createdBy']
).filter(
ShoutReactionsFollower.shoutId == rr.shoutId
ShoutReactionsFollower.shout == rr.shout
).first()
if not following2:
following2 = ShoutReactionsFollower.create(
followerId=re_reaction_dict['createdBy'],
shoutId=rr.shoutId,
follower=re_reaction_dict['createdBy'],
shout=rr.shout,
auto=True
)
session.add(following2)
@@ -190,13 +190,13 @@ def migrate_2stage(rr, old_new_id):
session.add(comment)
srf = session.query(ShoutReactionsFollower).where(
ShoutReactionsFollower.shoutId == comment.shoutId
ShoutReactionsFollower.shout == comment.shout
).filter(
ShoutReactionsFollower.followerId == comment.createdBy
ShoutReactionsFollower.follower == comment.createdBy
).first()
if not srf:
srf = ShoutReactionsFollower.create(shoutId=comment.shoutId, followerId=comment.createdBy, auto=True)
srf = ShoutReactionsFollower.create(shout=comment.shout, follower=comment.createdBy, auto=True)
session.add(srf)
session.commit()

View File

@@ -91,12 +91,12 @@ async def create_shout(shout_dict, userslug):
).join(
User
).where(
ShoutReactionsFollower.shoutId == s.id
ShoutReactionsFollower.shout == s.id
).filter(
User.slug == userslug
).first()
if not srf:
srf = ShoutReactionsFollower.create(shoutId=s.id, followerId=follower.id, auto=True)
srf = ShoutReactionsFollower.create(shout=s.id, follower=follower.id, auto=True)
session.add(srf)
session.commit()
@@ -226,15 +226,15 @@ async def add_topics_follower(entry, storage, userslug):
tf = session.query(
TopicFollower
).where(
TopicFollower.followerId == follower.id
TopicFollower.follower == follower.id
).filter(
TopicFollower.topicId == topic.id
TopicFollower.topic == topic.id
).first()
if not tf:
tf = TopicFollower.create(
topicId=topic.id,
followerId=follower.id,
topic=topic.id,
follower=follower.id,
auto=True
)
session.add(tf)
@@ -325,7 +325,7 @@ async def topics_aftermath(entry, storage):
.first()
)
if shout_topic_old:
shout_topic_old.update({"topicId": new_topic.id})
shout_topic_old.update({"topic": new_topic.id})
else:
shout_topic_new = (
session.query(ShoutTopic)
@@ -338,7 +338,7 @@ async def topics_aftermath(entry, storage):
if not shout_topic_new:
try:
ShoutTopic.create(
**{"shoutId": shout.id, "topicId": new_topic.id}
**{"shout": shout.id, "topic": new_topic.id}
)
except Exception:
print("[migration] shout topic error: " + newslug)
@@ -373,14 +373,14 @@ async def content_ratings_to_reactions(entry, slug):
if content_rating["value"] > 0
else ReactionKind.DISLIKE,
"createdBy": reactedBy.id,
"shoutId": shout.id,
"shout": shout.id,
}
cts = content_rating.get("createdAt")
if cts:
reaction_dict["createdAt"] = date_parse(cts)
reaction = (
session.query(Reaction).filter(
Reaction.shoutId == reaction_dict["shoutId"]
Reaction.shout == reaction_dict["shout"]
).filter(
Reaction.createdBy == reaction_dict["createdBy"]
).filter(

View File

@@ -124,14 +124,14 @@ def migrate_2stage(entry, id_map):
user_rating_dict = {
"value": rating_entry["value"],
"raterId": rater.id,
"userId": user.id,
"user": user.id,
}
user_rating = UserRating.create(**user_rating_dict)
if user_rating_dict['value'] > 0:
af = AuthorFollower.create(
authorId=user.id,
followerId=rater.id,
author=user.id,
follower=rater.id,
auto=True
)
session.add(af)