From aa9594009cdc90f9dc114dddd36ffef6ee51d7b4 Mon Sep 17 00:00:00 2001 From: Nikita Melkozerov Date: Tue, 22 Oct 2024 19:41:08 +0200 Subject: [PATCH] Fix created_at on upsert (#638) --- fixbackend/cloud_accounts/azure_subscription_repo.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fixbackend/cloud_accounts/azure_subscription_repo.py b/fixbackend/cloud_accounts/azure_subscription_repo.py index 066bb07b..6548f6ae 100644 --- a/fixbackend/cloud_accounts/azure_subscription_repo.py +++ b/fixbackend/cloud_accounts/azure_subscription_repo.py @@ -28,6 +28,7 @@ from fixbackend.types import AsyncSessionMaker from datetime import datetime +from fixcloudutils.util import utc class AzureSubscriptionCredentialsEntity(Base, CreatedUpdatedMixin): @@ -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 @@ -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()]