safraeli commited on
Commit
609c2d6
·
verified ·
1 Parent(s): ed9466a

Security fix: backend/api/routes/sensors.py

Browse files
Files changed (1) hide show
  1. backend/api/routes/sensors.py +2 -2
backend/api/routes/sensors.py CHANGED
@@ -153,7 +153,7 @@ async def temp_humidity(
153
  r = {"timestamp": ts.isoformat()}
154
  for col in ["airTemperature", "airHumidity"]:
155
  v = row.get(col)
156
- if v is not None and v == v:
157
  r[col] = round(float(v), 1)
158
  rows.append(r)
159
  return rows
@@ -175,7 +175,7 @@ async def ndvi_history(
175
  if not df.empty and "NDVI" in df.columns:
176
  for ts, row in df.iterrows():
177
  v = row.get("NDVI")
178
- if v is not None and v == v:
179
  rows.append({"timestamp": ts.isoformat(), "device": label, "ndvi": round(float(v), 4)})
180
  except Exception:
181
  pass
 
153
  r = {"timestamp": ts.isoformat()}
154
  for col in ["airTemperature", "airHumidity"]:
155
  v = row.get(col)
156
+ if v is not None and v == v: # NaN check (NaN != NaN)
157
  r[col] = round(float(v), 1)
158
  rows.append(r)
159
  return rows
 
175
  if not df.empty and "NDVI" in df.columns:
176
  for ts, row in df.iterrows():
177
  v = row.get("NDVI")
178
+ if v is not None and v == v: # NaN check (NaN != NaN)
179
  rows.append({"timestamp": ts.isoformat(), "device": label, "ndvi": round(float(v), 4)})
180
  except Exception:
181
  pass