Update routes/dem_pyc_hoan_thanh.py
Browse files- routes/dem_pyc_hoan_thanh.py +13 -23
routes/dem_pyc_hoan_thanh.py
CHANGED
|
@@ -1,40 +1,30 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
from collections import defaultdict
|
| 4 |
-
import os
|
| 5 |
-
|
| 6 |
-
router = APIRouter()
|
| 7 |
-
|
| 8 |
-
REPO_ID = "doluong6/Quatest1"
|
| 9 |
-
HF_TOKEN = os.environ.get("HF_TOKEN")
|
| 10 |
-
|
| 11 |
-
@router.get("/dem_pyc_hoan_thanh")
|
| 12 |
-
async def dem_pyc_hoan_thanh():
|
| 13 |
try:
|
| 14 |
all_files = list_repo_files(repo_id=REPO_ID, repo_type="dataset", token=HF_TOKEN)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
scan_files = [
|
| 18 |
f for f in all_files
|
| 19 |
-
if f.startswith("Khach_hang/")
|
|
|
|
|
|
|
| 20 |
]
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
for f in scan_files:
|
| 25 |
parts = f.split("/")
|
| 26 |
if len(parts) >= 3:
|
| 27 |
ten_khach = parts[1]
|
| 28 |
-
|
| 29 |
|
| 30 |
return {
|
| 31 |
-
"tong_so_hoan_thanh": len(
|
| 32 |
"khach_hang": {
|
| 33 |
khach: {
|
| 34 |
-
"
|
| 35 |
-
"
|
| 36 |
}
|
| 37 |
-
for khach, files in
|
| 38 |
}
|
| 39 |
}
|
| 40 |
|
|
|
|
| 1 |
+
@app.get("/dem_pyc_hoan_thanh")
|
| 2 |
+
def dem_pyc_hoan_thanh():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
try:
|
| 4 |
all_files = list_repo_files(repo_id=REPO_ID, repo_type="dataset", token=HF_TOKEN)
|
| 5 |
|
| 6 |
+
hoan_thanh_files = [
|
|
|
|
| 7 |
f for f in all_files
|
| 8 |
+
if f.startswith("Khach_hang/")
|
| 9 |
+
and "/Scan/" in f
|
| 10 |
+
and "GCN" in f.upper() # ✅ chỉ tính file chứa "GCN" (không phân biệt hoa/thường)
|
| 11 |
]
|
| 12 |
|
| 13 |
+
thong_ke = defaultdict(list)
|
| 14 |
+
for f in hoan_thanh_files:
|
|
|
|
| 15 |
parts = f.split("/")
|
| 16 |
if len(parts) >= 3:
|
| 17 |
ten_khach = parts[1]
|
| 18 |
+
thong_ke[ten_khach].append(f)
|
| 19 |
|
| 20 |
return {
|
| 21 |
+
"tong_so_hoan_thanh": len(hoan_thanh_files),
|
| 22 |
"khach_hang": {
|
| 23 |
khach: {
|
| 24 |
+
"so_hoan_thanh": len(files),
|
| 25 |
+
"danh_sach": files
|
| 26 |
}
|
| 27 |
+
for khach, files in thong_ke.items()
|
| 28 |
}
|
| 29 |
}
|
| 30 |
|