test recency fix
This commit is contained in:
@@ -164,11 +164,12 @@ class PowerDB:
|
||||
peak = data.get('outagen', 0)
|
||||
# Clean areageom before insertion, referencing old power2.py logic
|
||||
areageom = remove_external_curly_braces(data.get('areageom'))
|
||||
current_time = datetime.now(timezone.utc)
|
||||
params = (
|
||||
data.get('incidentid'), utility_name, lat, lon,
|
||||
data.get('pointgeom'), areageom, start_time, data.get('etr'),
|
||||
data.get('outagen'), peak, data.get('cause'), data.get('crew_status'),
|
||||
True, data.get('last_change', datetime.now(timezone.utc)), datetime.now(timezone.utc), # last_change, fetch_time
|
||||
True, current_time, current_time, # last_change, fetch_time (always update last_change when seen in current fetch)
|
||||
lon, lat, unique_outage_key # geom, unique_outage_key
|
||||
)
|
||||
with self.conn.cursor() as cursor:
|
||||
@@ -181,8 +182,8 @@ class PowerDB:
|
||||
cursor.execute('UPDATE newpower SET state = c.state FROM public.county c WHERE ST_Contains(c.geom, newpower.geom) AND newpower.state IS NULL')
|
||||
cursor.execute('UPDATE newpower SET cwa = f.cwa FROM public.fzone f WHERE ST_Contains(f.geom, newpower.geom) AND newpower.cwa IS NULL')
|
||||
cursor.execute('UPDATE newpower SET realareageom = ST_LineFromEncodedPolyline(areageom) WHERE areageom IS NOT NULL AND realareageom IS NULL')
|
||||
cursor.execute("UPDATE newpower SET active = TRUE WHERE fetch_time > NOW() - INTERVAL '30 minutes'")
|
||||
cursor.execute("UPDATE newpower SET active = FALSE WHERE fetch_time < NOW() - INTERVAL '30 minutes'")
|
||||
cursor.execute("UPDATE newpower SET active = TRUE WHERE last_change > NOW() - INTERVAL '30 minutes'")
|
||||
cursor.execute("UPDATE newpower SET active = FALSE WHERE last_change < NOW() - INTERVAL '30 minutes'")
|
||||
cursor.execute("DELETE FROM newpower WHERE fetch_time < NOW() - INTERVAL '365 days'")
|
||||
logger.info("Post-processing complete.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user