Skip to content

Commit

Permalink
fix: upsert documents
Browse files Browse the repository at this point in the history
  • Loading branch information
MagicTheDev committed Apr 14, 2024
1 parent 5ba363b commit f26da97
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion bot/clan/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ async def raid_weekend_track(clan_tags: List[str], db_client: MongoDatabase, coc

current_raids: Dict[str, coc.RaidLogEntry] = {r[0].clan_tag : r[0] for r in current_raids if r and not isinstance(r, BaseException)}


db_updates = []
for clan_tag in clan_tags:
current_raid = current_raids.get(clan_tag)
Expand All @@ -151,7 +152,7 @@ async def raid_weekend_track(clan_tags: List[str], db_client: MongoDatabase, coc
continue

if current_raid._raw_data != previous_raid:
db_updates.append(UpdateOne({"tag" : clan_tag}, {"$set" : {"data" : current_raid._raw_data}}))
db_updates.append(UpdateOne({"tag" : clan_tag}, {"$set" : {"data" : current_raid._raw_data}}, upsert=True))

if previous_raid is None:
continue
Expand Down

0 comments on commit f26da97

Please sign in to comment.