from net import *
import pandas as pd
c=Client();first=json.loads((R/'probes/recent_range.json').read_text());rows=first['reviews'];cursor=first['cursor'];params=first['params'];pages=[]
for i in range(1,4):
    raw=json.loads(c.get('https://store.steampowered.com/appreviews/915310',params|{'cursor':cursor},'date_filter_validation'))
    safe=[{k:x.get(k) for k in ['recommendationid','timestamp_created','timestamp_updated','voted_up','steam_purchase']} for x in raw.get('reviews',[])]
    record={'params':params|{'cursor':cursor},'query_summary':raw.get('query_summary'),'cursor':raw.get('cursor'),'reviews':safe};dump(R/'probes'/f'recent_range_page{i}.json',record);pages.append(len(safe));rows.extend(safe)
    if not safe:break
    assert raw.get('cursor')!=cursor;cursor=raw['cursor']
else:raise AssertionError('Probe did not terminate')
d=pd.DataFrame(rows).drop_duplicates('recommendationid');old=pd.read_parquet(R.parent/'career-history-2026-09-06/reviews.parquet');old=old[old.appid.eq(915310)&old.timestamp_created.ge(params['start_date'])&old.timestamp_created.lt(params['end_date'])]
out={'returned':len(d),'summary':first['query_summary']['total_reviews'],'pages_after_first':pages,'all_dates_in_range':bool(d.timestamp_created.ge(params['start_date']).all()&d.timestamp_created.lt(params['end_date']).all()),'existing_history_count':len(old),'new_ids':sorted(set(d.recommendationid)-set(old.recommendationid)),'missing_old_ids':sorted(set(old.recommendationid)-set(d.recommendationid))}
assert out['all_dates_in_range'] and len(d)==out['summary'];assert not out['new_ids'] and not out['missing_old_ids'],out
dump(R/'date_filter_validation.json',out);print(json.dumps(out,indent=2))
