add metagoups & search on metagroup_id
This commit is contained in:
@@ -7,7 +7,7 @@ if os.getenv("POSTGRES_HOST"):
|
||||
echo=False, future=True)
|
||||
else:
|
||||
sqlite_file_name = os.getenv("SQLITE_DB_PATH", "eveal.db")
|
||||
engine = create_engine(f"sqlite:///{sqlite_file_name}", echo=False, future=True, connect_args={"check_same_thread": False})
|
||||
engine = create_engine(f"sqlite:///{sqlite_file_name}", echo=True, future=True, connect_args={"check_same_thread": False})
|
||||
|
||||
def get_session():
|
||||
db = Session(engine)
|
||||
|
||||
@@ -51,7 +51,7 @@ async def sde_types(sde_type: int | str, db: Session = Depends(get_session)) ->
|
||||
|
||||
|
||||
@app.post("/sde/types/search")
|
||||
async def sde_types_search(query: List[Dict[Literal["id", "name", "name_i", "marketgroup_id"], int | str]], db: Session = Depends(get_session)) -> List[models_sde.SDEType]:
|
||||
async def sde_types_search(query: List[Dict[Literal["id", "name", "name_i", "marketgroup_id", "metagroup_id"], int | str]], db: Session = Depends(get_session)) -> List[models_sde.SDEType]:
|
||||
items = []
|
||||
for q in query:
|
||||
for k in q.keys():
|
||||
|
||||
@@ -15,6 +15,7 @@ class SDEIcon(SQLModel, table=True):
|
||||
groups: List['SDEGroup'] = DynamicRelationship(back_populates="icon")
|
||||
marketgroups: List['SDEMarketGroup'] = DynamicRelationship(back_populates="icon")
|
||||
types: List['SDEType'] = DynamicRelationship(back_populates="icon")
|
||||
metagroups: List['SDEMetaGroup'] = DynamicRelationship(back_populates="icon")
|
||||
|
||||
|
||||
class SDECategory(SQLModel, table=True):
|
||||
@@ -69,6 +70,18 @@ class SDEMarketGroup(SQLModel, table=True):
|
||||
types: List['SDEType'] = DynamicRelationship(back_populates="marketgroup")
|
||||
|
||||
|
||||
class SDEMetaGroup(SQLModel, table=True):
|
||||
id: int = Field(primary_key=True)
|
||||
|
||||
name: str
|
||||
iconSuffix: Optional[str] = None
|
||||
|
||||
icon_id: Optional[int] = Field(default=None, foreign_key="sdeicon.id")
|
||||
icon: Optional[SDEIcon] = Relationship(back_populates="metagroups")
|
||||
|
||||
types: List['SDEType'] = DynamicRelationship(back_populates="metagroup")
|
||||
|
||||
|
||||
class SDEType(SQLModel, table=True):
|
||||
id: int = Field(primary_key=True)
|
||||
|
||||
@@ -78,6 +91,9 @@ class SDEType(SQLModel, table=True):
|
||||
marketgroup_id: Optional[int] = Field(default=None, foreign_key="sdemarketgroup.id")
|
||||
marketgroup: Optional[SDEMarketGroup] = Relationship(back_populates="types")
|
||||
|
||||
metagroup_id: Optional[int] = Field(default=None, foreign_key="sdemetagroup.id")
|
||||
metagroup: Optional[SDEMetaGroup] = Relationship(back_populates="types")
|
||||
|
||||
name: str
|
||||
published: bool = False
|
||||
description: Optional[str] = None
|
||||
|
||||
Reference in New Issue
Block a user