Skip to content

Commit

Permalink
Refactor: ensurer revision documents with created_at field is added/m…
Browse files Browse the repository at this point in the history
…odified on point of creation
  • Loading branch information
aybruhm committed Apr 23, 2024
1 parent 3b34463 commit 0e5fa14
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions agenta-backend/agenta_backend/models/db_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class AppVariantRevisionsDB(Document):
modified_by: Link[UserDB]
base: Link[VariantBaseDB]
config: ConfigDB
created_at: Optional[datetime] = Field(default=datetime.now())
created_at: datetime
updated_at: Optional[datetime] = Field(default=datetime.now())

class Settings:
Expand All @@ -131,7 +131,7 @@ class AppEnvironmentRevisionDB(Document):
modified_by: Link[UserDB]
deployed_app_variant_revision: Optional[PydanticObjectId]
deployment: Optional[PydanticObjectId] # reference to deployment
created_at: Optional[datetime] = Field(default=datetime.utcnow())
created_at: datetime

class Settings:
name = "environments_revisions"
Expand Down
4 changes: 4 additions & 0 deletions agenta-backend/agenta_backend/services/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ async def create_new_app_variant(
modified_by=user,
base=base,
config=config,
created_at=datetime.now()
)
await variant_revision.create()

Expand Down Expand Up @@ -891,6 +892,7 @@ async def add_variant_from_base_and_config(
modified_by=user_db,
base=base_db,
config=config_db,
created_at=datetime.now()
)
await variant_revision.create()

Expand Down Expand Up @@ -1284,6 +1286,7 @@ async def create_environment_revision(
environment=environment,
revision=environment.revision,
modified_by=user,
created_at=datetime.now()
)

if kwargs:
Expand Down Expand Up @@ -1497,6 +1500,7 @@ async def update_variant_parameters(
modified_by=user,
base=app_variant_db.base,
config=config_db,
created_at=datetime.now()
)
await variant_revision.save()

Expand Down

0 comments on commit 0e5fa14

Please sign in to comment.