petermutwiri commited on
Commit
c9de484
·
verified ·
1 Parent(s): e4c695c

Update app/mapper.py

Browse files
Files changed (1) hide show
  1. app/mapper.py +7 -7
app/mapper.py CHANGED
@@ -95,18 +95,18 @@ def canonify_df(org_id: str, hours_window: int = 24) -> pd.DataFrame:
95
  conn = get_conn(org_id)
96
  ensure_raw_table(conn)
97
 
98
- # 1️⃣ optional timestamp filter
99
  cutoff_str = ""
100
- if hours_window > 0: # allow 0 = disable filter
101
  cutoff = datetime.utcnow() - timedelta(hours=hours_window)
102
  cutoff_str = cutoff.strftime('%Y-%m-%d %H:%M:%S')
103
 
104
  rows = sql(conn, f"""
105
- SELECT row_data
106
- FROM raw_rows
107
- WHERE row_data IS NOT NULL
108
- AND LENGTH(row_data) > 0
109
- {f"AND try_strptime(NULLIF(json_extract(row_data, '$.timestamp'), ''), '%Y-%m-%d %H:%M:%S') >= TIMESTAMP '{cutoff_str}'" if hours_window > 0 else ""}
110
  """)
111
 
112
  if not rows:
 
95
  conn = get_conn(org_id)
96
  ensure_raw_table(conn)
97
 
98
+ # 1️⃣ optional timestamp filter (zero ? params)
99
  cutoff_str = ""
100
+ if hours_window > 0:
101
  cutoff = datetime.utcnow() - timedelta(hours=hours_window)
102
  cutoff_str = cutoff.strftime('%Y-%m-%d %H:%M:%S')
103
 
104
  rows = sql(conn, f"""
105
+ SELECT row_data
106
+ FROM raw_rows
107
+ WHERE row_data IS NOT NULL
108
+ AND LENGTH(row_data) > 0
109
+ {f"AND try_strptime(NULLIF(json_extract(row_data, '$.timestamp'), ''), '%Y-%m-%d %H:%M:%S') >= TIMESTAMP '{cutoff_str}'" if hours_window > 0 else ""}
110
  """)
111
 
112
  if not rows: