Explorer
/tmp/patch_newest.py
← Zurück ↓ Download
from pathlib import Path
p=Path('/opt/struktur/social-media-agent/app.py')
s=p.read_text()
old='"newest":       "pinned DESC, COALESCE(observed_at, created_at, timestamp) DESC, radar_score DESC",'
new='"newest":       "pinned DESC, CASE WHEN lower(source_type) = \'meta_ad\' THEN COALESCE(ad_start_at, \'\') ELSE COALESCE(published_at, \'\') END DESC, observed_at DESC, radar_score DESC",'
if old not in s: raise SystemExit('newest anchor missing')
p.write_text(s.replace(old,new,1))