use user slug as rater in Comment and User ratings
This commit is contained in:
@@ -71,14 +71,13 @@ def migrate(entry, shouts_by_oid):
|
||||
if rater and comment:
|
||||
comment_rating_dict = {
|
||||
'value': comment_rating_old['value'],
|
||||
'createdBy': rater.id,
|
||||
'createdBy': rater.slug,
|
||||
'comment_id': comment.id
|
||||
}
|
||||
cts = comment_rating_old.get('createdAt')
|
||||
if cts: comment_rating_dict['createdAt'] = date_parse(cts)
|
||||
try:
|
||||
comment_rating = CommentRating.create(**comment_rating_dict)
|
||||
# comment_rating_dict['id'] = comment_rating.id
|
||||
comment_dict['ratings'].append(comment_rating_dict)
|
||||
except Exception as e:
|
||||
print(comment_rating_dict)
|
||||
|
@@ -217,11 +217,11 @@ def migrate(entry, users_by_oid, topics_by_oid):
|
||||
if rater:
|
||||
shout_rating_dict = {
|
||||
'value': shout_rating_old['value'],
|
||||
'rater': rater.id,
|
||||
'rater': rater.slug,
|
||||
'shout': s.slug
|
||||
}
|
||||
cts = shout_rating_old.get('createdAt')
|
||||
if cts: shout_rating_dict['rater_id'] = date_parse(cts)
|
||||
if cts: shout_rating_dict['ts'] = date_parse(cts)
|
||||
try: shout_rating = ShoutRating.create(**shout_rating_dict)
|
||||
except sqlalchemy.exc.IntegrityError: pass
|
||||
shout_dict['ratings'].append(shout_rating_dict)
|
||||
|
@@ -91,13 +91,13 @@ def migrate(entry):
|
||||
def migrate_2stage(entry, id_map):
|
||||
for rating_entry in entry.get('ratings',[]):
|
||||
rater_old_id = rating_entry['createdBy']
|
||||
rater_id = id_map.get(rater_old_id)
|
||||
if not rater_id:
|
||||
rater_slug = id_map.get(rater_old_id)
|
||||
if not rater_slug:
|
||||
continue
|
||||
old_id = entry['_id']
|
||||
user_rating_dict = {
|
||||
'value': rating_entry['value'],
|
||||
'rater': rater_id,
|
||||
'rater': rater_slug,
|
||||
'user': id_map.get(old_id)
|
||||
}
|
||||
with local_session() as session:
|
||||
|
Reference in New Issue
Block a user