Skip to content

Commit

Permalink
feat(backend): Store last_update time
Browse files Browse the repository at this point in the history
  • Loading branch information
RezaRahemtola committed Oct 30, 2024
1 parent 024f1db commit 87c5d83
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions backend/src/interfaces/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Agent(BaseModel):
subscription_id: str
vm_hash: str | None
encrypted_secret: str
last_update: int
tags: list[str]


Expand Down
6 changes: 5 additions & 1 deletion backend/src/main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from http import HTTPStatus
from uuid import uuid4

Expand Down Expand Up @@ -48,6 +49,7 @@ async def setup(body: SetupAgentBody) -> None:
subscription_id=body.subscription_id,
vm_hash=None,
encrypted_secret=encrypted_secret,
last_update=int(time.time()),
tags=[agent_id, body.subscription_id, body.account.address],
)

Expand Down Expand Up @@ -127,7 +129,9 @@ async def update(body: UpdateAgentPutBody, code: UploadFile, packages: UploadFil
# Updating the related POST message
await client.create_post(
post_content=Agent(
**agent.dict(exclude={"vm_hash"}), vm_hash=message.item_hash
**agent.dict(exclude={"vm_hash", "last_update"}),
vm_hash=message.item_hash,
last_update=int(time.time()),
),
post_type="amend",
ref=agent.post_hash,
Expand Down

0 comments on commit 87c5d83

Please sign in to comment.