vanitha commited on
Commit
ed5ceb6
·
1 Parent(s): cd7e15d

(service-catalogue)-fix advanced filter

Browse files
app/service_catalogue/schemas/schema.py CHANGED
@@ -1,7 +1,7 @@
1
  """
2
  Pydantic schemas for Service Catalogue API.
3
  """
4
- from typing import Optional, List, Dict, Any
5
  from pydantic import BaseModel, Field, constr
6
 
7
 
@@ -59,8 +59,8 @@ class ServiceResponse(BaseModel):
59
 
60
  class ListServicesRequest(BaseModel):
61
  merchant_id: Optional[str] = None
62
- status: Optional[str] = Field(None, pattern="^(active|inactive|archived)$")
63
- category: Optional[str] = None
64
  skip: int = Field(0, ge=0)
65
  limit: int = Field(100, ge=1, le=1000)
66
  projection_list: Optional[List[str]] = Field(
 
1
  """
2
  Pydantic schemas for Service Catalogue API.
3
  """
4
+ from typing import Literal, Optional, List, Dict, Any
5
  from pydantic import BaseModel, Field, constr
6
 
7
 
 
59
 
60
  class ListServicesRequest(BaseModel):
61
  merchant_id: Optional[str] = None
62
+ status: Optional[List[Literal["active", "inactive", "archived"]]] = None
63
+ category: Optional[list[str]] = None
64
  skip: int = Field(0, ge=0)
65
  limit: int = Field(100, ge=1, le=1000)
66
  projection_list: Optional[List[str]] = Field(
app/service_catalogue/services/service.py CHANGED
@@ -90,8 +90,8 @@ async def get_service(service_id: str) -> Optional[dict]:
90
 
91
  async def list_services(
92
  merchant_id: str,
93
- status: Optional[str] = None,
94
- category: Optional[str] = None,
95
  skip: int = 0,
96
  limit: int = 100,
97
  projection_list: Optional[List[str]] = None
@@ -104,9 +104,9 @@ async def list_services(
104
  merchant_id_str = str(merchant_id)
105
  query = {"merchant_id": merchant_id_str}
106
  if status:
107
- query["status"] = status
108
  if category:
109
- query["category.id"] = category
110
 
111
  # Build MongoDB projection
112
  projection_dict = None
 
90
 
91
  async def list_services(
92
  merchant_id: str,
93
+ status: Optional[list[str]] = None,
94
+ category: Optional[list[str]] = None,
95
  skip: int = 0,
96
  limit: int = 100,
97
  projection_list: Optional[List[str]] = None
 
104
  merchant_id_str = str(merchant_id)
105
  query = {"merchant_id": merchant_id_str}
106
  if status:
107
+ query["status"] = {"$in": status}
108
  if category:
109
+ query["category.id"] = {"$in": category}
110
 
111
  # Build MongoDB projection
112
  projection_dict = None