Spaces:
Sleeping
Sleeping
fix(deploy): prevent undetected plates from matching on the same N/A sessions
Browse files- app/api/predict.py +13 -8
app/api/predict.py
CHANGED
|
@@ -145,14 +145,19 @@ def _resolve_or_create_open_parking_session(*, vehicle_id: Optional[str], create
|
|
| 145 |
if vehicle_id:
|
| 146 |
params["vehicle_id"] = f"eq.{vehicle_id}"
|
| 147 |
elif plate_arabic or plate_english:
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
if
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
else:
|
| 157 |
return None
|
| 158 |
open_response = requests.get(
|
|
|
|
| 145 |
if vehicle_id:
|
| 146 |
params["vehicle_id"] = f"eq.{vehicle_id}"
|
| 147 |
elif plate_arabic or plate_english:
|
| 148 |
+
is_ar_valid = plate_arabic and plate_arabic.upper() not in {"", "N/A", "NONE", "NULL", "-"}
|
| 149 |
+
is_en_valid = plate_english and plate_english.upper() not in {"", "N/A", "NONE", "NULL", "-"}
|
| 150 |
+
if is_ar_valid or is_en_valid:
|
| 151 |
+
params["vehicle_id"] = "is.null"
|
| 152 |
+
plate_filters = []
|
| 153 |
+
if is_ar_valid:
|
| 154 |
+
plate_filters.append(f"plate_arabic.eq.{plate_arabic}")
|
| 155 |
+
if is_en_valid:
|
| 156 |
+
plate_filters.append(f"plate_english.eq.{plate_english}")
|
| 157 |
+
if plate_filters:
|
| 158 |
+
params["or"] = f"({','.join(plate_filters)})"
|
| 159 |
+
else:
|
| 160 |
+
return None
|
| 161 |
else:
|
| 162 |
return None
|
| 163 |
open_response = requests.get(
|