Pant0x commited on
Commit
bde789b
·
1 Parent(s): 4364e60

fix(deploy): prevent undetected plates from matching on the same N/A sessions

Browse files
Files changed (1) hide show
  1. 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
- params["vehicle_id"] = "is.null"
149
- plate_filters = []
150
- if plate_arabic:
151
- plate_filters.append(f"plate_arabic.eq.{plate_arabic}")
152
- if plate_english:
153
- plate_filters.append(f"plate_english.eq.{plate_english}")
154
- if plate_filters:
155
- params["or"] = f"({','.join(plate_filters)})"
 
 
 
 
 
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(