Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Commit

Permalink
fix MeowID migrator
Browse files Browse the repository at this point in the history
  • Loading branch information
tnix100 authored Aug 13, 2024
1 parent cd00581 commit 0204117
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ def get_total_pages(collection: str, query: dict, page_size: int = 25) -> int:
updates: list[pymongo.UpdateOne] = []
for post in db.get_collection("posts").find({"meowid": {"$exists": False}}, projection={"_id": 1, "t.e": 1}):
updates.append(pymongo.UpdateOne({"_id": post["_id"]}, {"$set": {"meowid": gen_id_injected(post["t"]["e"])}}))
db.get_collection("posts").bulk_write(updates)
if len(updates):
db.get_collection("posts").bulk_write(updates)

log("[Migrator] Adding MeowID to chats")
updates: list[pymongo.UpdateOne] = []
Expand All @@ -321,7 +322,8 @@ def get_total_pages(collection: str, query: dict, page_size: int = 25) -> int:
if time is None:
time = (MEOWER_EPOCH // 1000)
updates.append(pymongo.UpdateOne({"_id": chat["_id"]}, {"$set": {"meowid": gen_id_injected(time)}}))
db.get_collection("chats").bulk_write(updates)
if len(updates):
db.get_collection("chats").bulk_write(updates)

log("[Migrator] Adding MeowID to usersv0")
updates: list[pymongo.UpdateOne] = []
Expand All @@ -330,8 +332,9 @@ def get_total_pages(collection: str, query: dict, page_size: int = 25) -> int:
if time is None:
time = (MEOWER_EPOCH // 1000)
updates.append(pymongo.UpdateOne({"_id": user["_id"]}, {"$set": {"meowid": gen_id_injected(time)}}))
db.get_collection("usersv0").bulk_write(updates)
db.get_collection("user_settings").bulk_write(updates)
if len(updates):
db.get_collection("usersv0").bulk_write(updates)
db.get_collection("user_settings").bulk_write(updates)



Expand Down

0 comments on commit 0204117

Please sign in to comment.