Skip to content

Commit

Permalink
Fix created_at on upsert (#638)
Browse files Browse the repository at this point in the history
  • Loading branch information
meln1k authored Oct 22, 2024
1 parent eb1810f commit aa95940
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion fixbackend/cloud_accounts/azure_subscription_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from fixbackend.types import AsyncSessionMaker

from datetime import datetime
from fixcloudutils.util import utc


class AzureSubscriptionCredentialsEntity(Base, CreatedUpdatedMixin):
Expand Down Expand Up @@ -81,6 +82,7 @@ async def upsert(
existing.azure_tenant_id = azure_tenant_id
existing.client_id = client_id
existing.client_secret = client_secret
existing.created_at = utc() # update to trigger list_created_after
model = existing.to_model()
await session.commit()
return model
Expand Down Expand Up @@ -121,7 +123,7 @@ async def get_by_tenant(self, tenant_id: WorkspaceId) -> Optional[AzureSubscript
async def list_created_after(self, time: datetime) -> List[AzureSubscriptionCredentials]:
async with self._session_maker() as session:
query = select(AzureSubscriptionCredentialsEntity).filter(
AzureSubscriptionCredentialsEntity.updated_at > time
AzureSubscriptionCredentialsEntity.created_at > time
)
result = await session.execute(query)
return [entity.to_model() for entity in result.scalars()]
Expand Down

0 comments on commit aa95940

Please sign in to comment.