focustiki commited on
Commit
557593d
·
1 Parent(s): e2c2f42

Fix: Ensure weather_type and temp_c are written at insert time in fallback_direct_insert; pass weather into fallback calls so columns populate correctly on both tables.

Browse files
Files changed (1) hide show
  1. streamlit_app.py +7 -5
streamlit_app.py CHANGED
@@ -785,7 +785,7 @@ def main():
785
  fallback_direct_insert(user_email, int(v["id"]), name_clean, int(quantity),
786
  clean_text(category,80), clean_text(unit,40),
787
  clean_text(barcode,64), ts_iso, ingest_id,
788
- )
789
  # After fallback insert, attach weather fields as part of payload
790
  try:
791
  if weather_type is not None or temp_c is not None:
@@ -806,7 +806,8 @@ def main():
806
  try:
807
  fallback_direct_insert(user_email, int(v["id"]), name_clean, int(quantity),
808
  clean_text(category,80), clean_text(unit,40),
809
- clean_text(barcode,64), ts_iso, ingest_id)
 
810
  # Attach weather after direct insert
811
  try:
812
  if weather_type is not None or temp_c is not None:
@@ -1124,7 +1125,8 @@ def try_rpc_ingest(email: str, v_id: int, name: str, qty: int,
1124
 
1125
  def fallback_direct_insert(email: str, v_id: int, name: str, qty: int,
1126
  category: Optional[str], unit: Optional[str],
1127
- barcode: Optional[str], ts_iso: str, ingest_id: str) -> None:
 
1128
  """Enhanced fallback insertion with better error handling"""
1129
  payload = {
1130
  "visit_id": v_id,
@@ -1135,8 +1137,8 @@ def fallback_direct_insert(email: str, v_id: int, name: str, qty: int,
1135
  "unit": unit,
1136
  "qty": qty,
1137
  "barcode": barcode,
1138
- "weather_type": None,
1139
- "temp_c": None,
1140
  "ingest_id": ingest_id
1141
  }
1142
 
 
785
  fallback_direct_insert(user_email, int(v["id"]), name_clean, int(quantity),
786
  clean_text(category,80), clean_text(unit,40),
787
  clean_text(barcode,64), ts_iso, ingest_id,
788
+ weather_type=weather_type, temp_c=temp_c)
789
  # After fallback insert, attach weather fields as part of payload
790
  try:
791
  if weather_type is not None or temp_c is not None:
 
806
  try:
807
  fallback_direct_insert(user_email, int(v["id"]), name_clean, int(quantity),
808
  clean_text(category,80), clean_text(unit,40),
809
+ clean_text(barcode,64), ts_iso, ingest_id,
810
+ weather_type=weather_type, temp_c=temp_c)
811
  # Attach weather after direct insert
812
  try:
813
  if weather_type is not None or temp_c is not None:
 
1125
 
1126
  def fallback_direct_insert(email: str, v_id: int, name: str, qty: int,
1127
  category: Optional[str], unit: Optional[str],
1128
+ barcode: Optional[str], ts_iso: str, ingest_id: str,
1129
+ weather_type: Optional[str] = None, temp_c: Optional[float] = None) -> None:
1130
  """Enhanced fallback insertion with better error handling"""
1131
  payload = {
1132
  "visit_id": v_id,
 
1137
  "unit": unit,
1138
  "qty": qty,
1139
  "barcode": barcode,
1140
+ "weather_type": weather_type,
1141
+ "temp_c": temp_c,
1142
  "ingest_id": ingest_id
1143
  }
1144