chawin.chen Qwen-Coder commited on
Commit ·
75a5800
1
Parent(s): eca1538
feat: 检测历史新增平台筛选功能
Browse files- models.py SearchRequest 新增 platform 字段
- database.py fetch_paged_image_records/count_image_records 支持 platform 筛选
- android 查询 nickname like 'android%'
- ios 查询 nickname like 'ios%'
- miniprogram 查询 region = ''
- all 不增加额外查询条件
- api_routes.py outputs 接口传递 platform 参数
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
- api_routes.py +3 -0
- database.py +20 -0
- models.py +1 -0
api_routes.py
CHANGED
|
@@ -2127,10 +2127,12 @@ async def list_outputs(
|
|
| 2127 |
logger.info("Returning regular file list")
|
| 2128 |
try:
|
| 2129 |
region_filter = request.region if hasattr(request, 'region') else None
|
|
|
|
| 2130 |
total_count = await count_image_records(
|
| 2131 |
category=category,
|
| 2132 |
nickname=nickname_filter,
|
| 2133 |
region=region_filter,
|
|
|
|
| 2134 |
is_cropped_face=is_cropped_filter,
|
| 2135 |
)
|
| 2136 |
if total_count > 0:
|
|
@@ -2139,6 +2141,7 @@ async def list_outputs(
|
|
| 2139 |
category=category,
|
| 2140 |
nickname=nickname_filter,
|
| 2141 |
region=region_filter,
|
|
|
|
| 2142 |
offset=offset,
|
| 2143 |
limit=page_size,
|
| 2144 |
is_cropped_face=is_cropped_filter,
|
|
|
|
| 2127 |
logger.info("Returning regular file list")
|
| 2128 |
try:
|
| 2129 |
region_filter = request.region if hasattr(request, 'region') else None
|
| 2130 |
+
platform_filter = request.platform if hasattr(request, 'platform') else None
|
| 2131 |
total_count = await count_image_records(
|
| 2132 |
category=category,
|
| 2133 |
nickname=nickname_filter,
|
| 2134 |
region=region_filter,
|
| 2135 |
+
platform=platform_filter,
|
| 2136 |
is_cropped_face=is_cropped_filter,
|
| 2137 |
)
|
| 2138 |
if total_count > 0:
|
|
|
|
| 2141 |
category=category,
|
| 2142 |
nickname=nickname_filter,
|
| 2143 |
region=region_filter,
|
| 2144 |
+
platform=platform_filter,
|
| 2145 |
offset=offset,
|
| 2146 |
limit=page_size,
|
| 2147 |
is_cropped_face=is_cropped_filter,
|
database.py
CHANGED
|
@@ -180,6 +180,7 @@ async def fetch_paged_image_records(
|
|
| 180 |
category: Optional[str],
|
| 181 |
nickname: Optional[str],
|
| 182 |
region: Optional[str] = None,
|
|
|
|
| 183 |
offset: int,
|
| 184 |
limit: int,
|
| 185 |
is_cropped_face: Optional[int] = None,
|
|
@@ -193,6 +194,15 @@ async def fetch_paged_image_records(
|
|
| 193 |
if nickname:
|
| 194 |
where_clauses.append("nickname LIKE %s")
|
| 195 |
params.append(f"{nickname}%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
if region:
|
| 197 |
where_clauses.append("region = %s")
|
| 198 |
params.append(region)
|
|
@@ -226,6 +236,7 @@ async def count_image_records(
|
|
| 226 |
category: Optional[str],
|
| 227 |
nickname: Optional[str],
|
| 228 |
region: Optional[str] = None,
|
|
|
|
| 229 |
is_cropped_face: Optional[int] = None,
|
| 230 |
) -> int:
|
| 231 |
"""按条件统计图片记录数量"""
|
|
@@ -237,6 +248,15 @@ async def count_image_records(
|
|
| 237 |
if nickname:
|
| 238 |
where_clauses.append("nickname LIKE %s")
|
| 239 |
params.append(f"{nickname}%")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 240 |
if region:
|
| 241 |
where_clauses.append("region = %s")
|
| 242 |
params.append(region)
|
|
|
|
| 180 |
category: Optional[str],
|
| 181 |
nickname: Optional[str],
|
| 182 |
region: Optional[str] = None,
|
| 183 |
+
platform: Optional[str] = None,
|
| 184 |
offset: int,
|
| 185 |
limit: int,
|
| 186 |
is_cropped_face: Optional[int] = None,
|
|
|
|
| 194 |
if nickname:
|
| 195 |
where_clauses.append("nickname LIKE %s")
|
| 196 |
params.append(f"{nickname}%")
|
| 197 |
+
if platform == "android":
|
| 198 |
+
where_clauses.append("nickname LIKE %s")
|
| 199 |
+
params.append("android%")
|
| 200 |
+
elif platform == "ios":
|
| 201 |
+
where_clauses.append("nickname LIKE %s")
|
| 202 |
+
params.append("ios%")
|
| 203 |
+
elif platform == "miniprogram":
|
| 204 |
+
where_clauses.append("region = %s")
|
| 205 |
+
params.append("")
|
| 206 |
if region:
|
| 207 |
where_clauses.append("region = %s")
|
| 208 |
params.append(region)
|
|
|
|
| 236 |
category: Optional[str],
|
| 237 |
nickname: Optional[str],
|
| 238 |
region: Optional[str] = None,
|
| 239 |
+
platform: Optional[str] = None,
|
| 240 |
is_cropped_face: Optional[int] = None,
|
| 241 |
) -> int:
|
| 242 |
"""按条件统计图片记录数量"""
|
|
|
|
| 248 |
if nickname:
|
| 249 |
where_clauses.append("nickname LIKE %s")
|
| 250 |
params.append(f"{nickname}%")
|
| 251 |
+
if platform == "android":
|
| 252 |
+
where_clauses.append("nickname LIKE %s")
|
| 253 |
+
params.append("android%")
|
| 254 |
+
elif platform == "ios":
|
| 255 |
+
where_clauses.append("nickname LIKE %s")
|
| 256 |
+
params.append("ios%")
|
| 257 |
+
elif platform == "miniprogram":
|
| 258 |
+
where_clauses.append("region = %s")
|
| 259 |
+
params.append("")
|
| 260 |
if region:
|
| 261 |
where_clauses.append("region = %s")
|
| 262 |
params.append(region)
|
models.py
CHANGED
|
@@ -32,6 +32,7 @@ class SearchRequest(BaseModel):
|
|
| 32 |
score_threshold: float = 0.0
|
| 33 |
nickname: Optional[str] = None
|
| 34 |
region: Optional[str] = None
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
class ImageSearchRequest(BaseModel):
|
|
|
|
| 32 |
score_threshold: float = 0.0
|
| 33 |
nickname: Optional[str] = None
|
| 34 |
region: Optional[str] = None
|
| 35 |
+
platform: Optional[str] = None
|
| 36 |
|
| 37 |
|
| 38 |
class ImageSearchRequest(BaseModel):
|