bug修改
This commit is contained in:
parent
fec659bdf4
commit
3cbe3604a2
|
@ -134,12 +134,16 @@ def load_user_data(db: Session):
|
|||
}
|
||||
post_list.extend(user_info["post"])
|
||||
user_list.append(user_info)
|
||||
# post_list.sort(key=lambda x: dp_id_dic[x[0]])
|
||||
# db.query(Post).delete()
|
||||
# for post in post_list:
|
||||
# new_post = Post(name=post[1], belong=dp_id_dic[post[0]])
|
||||
# db.add(new_post)
|
||||
# db.commit()
|
||||
post_list.sort(key=lambda x: dp_id_dic[x[0]])
|
||||
db.query(Post).delete()
|
||||
key_dic = set()
|
||||
for post in post_list:
|
||||
key = f"{post[0]},{post[1]}"
|
||||
if key not in key_dic:
|
||||
key_dic.add(key)
|
||||
new_post = Post(name=post[1], belong=dp_id_dic[post[0]])
|
||||
db.add(new_post)
|
||||
db.commit()
|
||||
dp_post_dic = {}
|
||||
for item in db.query(Post).all():
|
||||
if not dp_post_dic.get(item.belong):
|
||||
|
|
Loading…
Reference in New Issue