Skip to content

Commit 194317c

Browse files
committed
fix update query
1 parent d8cb59a commit 194317c

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

backend/btrixcloud/orgs.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from datetime import datetime
1515
from tempfile import NamedTemporaryFile
1616

17-
from typing import Optional, TYPE_CHECKING, Callable, List, AsyncGenerator
17+
from typing import Optional, TYPE_CHECKING, Callable, List, AsyncGenerator, Any
1818

1919
from pymongo import ReturnDocument
2020
from pymongo.errors import AutoReconnect, DuplicateKeyError
@@ -357,9 +357,16 @@ async def update_subscription_data(
357357
self, update: SubscriptionUpdate
358358
) -> Optional[Organization]:
359359
"""Update subscription by id"""
360+
361+
query: dict[str, Any] = {"subData.status": update.status}
362+
if update.futureCancelDate:
363+
query["subData.futureCancelDate"] = update.futureCancelDate
364+
if update.details:
365+
query["subData.details"] = update.details
366+
360367
org_data = await self.orgs.find_one_and_update(
361368
{"subData.subId": update.subId},
362-
{"$set": {"subData": update.dict(exclude_unset=True)}},
369+
{"$set": query},
363370
return_document=ReturnDocument.AFTER,
364371
)
365372
return Organization.from_dict(org_data) if org_data else None

0 commit comments

Comments
 (0)