Skip to content

Commit 856ef6e

Browse files
committed
make quota_updates update atomic in /quotas endpoint
1 parent 710e4b7 commit 856ef6e

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

backend/btrixcloud/orgs.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -632,20 +632,17 @@ async def update_quotas(
632632
exclude_unset=True, exclude_defaults=True, exclude_none=True
633633
)
634634

635-
quota_updates = []
636-
for prev_update in org.quotaUpdates or []:
637-
quota_updates.append(prev_update.dict())
638-
quota_updates.append(
639-
OrgQuotaUpdate(update=update, modified=dt_now(), context=context).dict()
640-
)
641-
642635
await self.orgs.find_one_and_update(
643636
{"_id": org.id},
644637
{
645638
"$set": {
646639
"quotas": update,
647-
"quotaUpdates": quota_updates,
648-
}
640+
},
641+
"$push": {
642+
"quotaUpdates": OrgQuotaUpdate(
643+
update=OrgQuotas(**update), modified=dt_now(), context=context
644+
).model_dump()
645+
},
649646
},
650647
)
651648

0 commit comments

Comments
 (0)