MCPcopy Index your code
hub / github.com/vastsa/FileCodeBox / _get_sort_value

Method _get_sort_value

apps/admin/services.py:1408–1427  ·  view source on GitHub ↗
(self, item: dict[str, Any], sort_by: str)

Source from the content-addressed store, hash-verified

1406 return normalized
1407
1408 def _get_sort_value(self, item: dict[str, Any], sort_by: str):
1409 def date_value(value: Any) -> float:
1410 if value is None:
1411 return 0
1412 if isinstance(value, datetime):
1413 return value.timestamp()
1414 return 0
1415
1416 sort_map = {
1417 "created_at": date_value(item.get("createdAt")),
1418 "createdat": date_value(item.get("createdAt")),
1419 "expired_at": date_value(item.get("expiredAt")),
1420 "expiredat": date_value(item.get("expiredAt")),
1421 "name": item.get("name") or "",
1422 "size": item.get("size") or 0,
1423 "used_count": item.get("usedCount") or 0,
1424 "usedcount": item.get("usedCount") or 0,
1425 "code": item.get("code") or "",
1426 }
1427 return sort_map.get(sort_by)
1428
1429 async def download_file(self, file_id: int):
1430 file_code = await FileCodes.filter(id=file_id).first()

Callers 1

list_filesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected