Clean up
This commit is contained in:
parent
bcf13b48f2
commit
43ec8ec01e
@ -1,6 +0,0 @@
|
||||
from app.common.daos.hello_world.hello_world_dao import HelloWorldDao
|
||||
|
||||
hello_world_dao = HelloWorldDao()
|
||||
|
||||
def get_hello_world_dao() -> HelloWorldDao:
|
||||
return hello_world_dao
|
||||
@ -1,30 +0,0 @@
|
||||
from app.common.models.hello_world.hello_world import HelloWorld
|
||||
|
||||
class HelloWorldDao:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
async def create_hello_world(self, message: str, count: int):
|
||||
hello_world = HelloWorld(message=message, count=count)
|
||||
await hello_world.insert()
|
||||
return hello_world
|
||||
|
||||
async def get_hello_world(self, id: str):
|
||||
hello_world = await HelloWorld.get(id)
|
||||
return hello_world
|
||||
|
||||
async def update_hello_world(self, id: str, message: str, count: int):
|
||||
hello_world = await HelloWorld.get(id)
|
||||
if hello_world:
|
||||
hello_world.message = message
|
||||
hello_world.count = count
|
||||
await hello_world.save()
|
||||
return hello_world
|
||||
return None
|
||||
|
||||
async def delete_hello_world(self, id: str):
|
||||
hello_world = await HelloWorld.get(id)
|
||||
if hello_world:
|
||||
await hello_world.delete()
|
||||
return True
|
||||
return False
|
||||
@ -1,5 +1,4 @@
|
||||
from app.common.models.hello_world.hello_world import HelloWorld
|
||||
from app.common.models.deployment.deployment import Deployment
|
||||
|
||||
# list of beanie document models
|
||||
db_models = [HelloWorld, Deployment]
|
||||
db_models = [Deployment]
|
||||
@ -2,12 +2,18 @@ from datetime import datetime
|
||||
from typing import Literal
|
||||
|
||||
from beanie import Document
|
||||
from pydantic import Field
|
||||
from bson import ObjectId
|
||||
from pydantic import Field, field_validator
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class Deployment(Document):
|
||||
deployment_id: str = Field(alias="_id")
|
||||
@field_validator("deployment_id", mode="before")
|
||||
@classmethod
|
||||
def convert_object_id(cls, v):
|
||||
return str(v)
|
||||
|
||||
deployment_stage: str
|
||||
deployment_status: Literal["started", "failed", "succeeded", "aborted"]
|
||||
|
||||
@ -31,7 +37,9 @@ class Deployment(Document):
|
||||
indexes = [
|
||||
[("deployment_product_id", 1), ("created_at", 1)], # Compound index
|
||||
[("deployment_id", 1), ("deployment_status", 1)], # Compound index
|
||||
{"keys": [("deployment_id", 1), ("deployment_stage", 1)], "unique": True} # Unique compound index
|
||||
|
||||
# somehow combo + unique errors out
|
||||
# {"keys": [("deployment_id", 1), ("deployment_stage", 1)], "unique": True} # Unique compound index
|
||||
]
|
||||
|
||||
class InitDeploymentRequest(BaseModel):
|
||||
|
||||
@ -1,17 +0,0 @@
|
||||
from datetime import datetime
|
||||
|
||||
from beanie import Document
|
||||
|
||||
|
||||
class HelloWorld(Document):
|
||||
message: str
|
||||
count: int = 0
|
||||
created_time: datetime = datetime.now()
|
||||
|
||||
class Settings:
|
||||
name = "hello_world"
|
||||
indexes = [
|
||||
[("message", 1), ("count", 1)]
|
||||
]
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ from typing import List
|
||||
from fastapi import APIRouter, Depends
|
||||
from loguru import logger
|
||||
|
||||
from app.common.daos.hello_world import get_hello_world_dao, HelloWorldDao
|
||||
from app.common.models.deployment.deployment import Deployment, InitDeploymentRequest
|
||||
from app.routes.deployment.service import DeploymentService, get_deployment_service
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user