benvinegar / counterscale

Scalable web analytics you run yourself on Cloudflare
https://counterscale.dev
MIT License
1.52k stars 66 forks source link

Some sites not selectable if no events within current time range #43

Closed benvinegar closed 7 months ago

benvinegar commented 9 months ago

Example when 30 days (all sites selectable, because there is traffic within 30 days):

image

But here's what happens when you choose 7 days:

image

benchmarking disappears because it had no traffic during that period.

Expected behavior: benchmarking should still be selectable, even if there's no reported traffic over that interval.

kandros commented 8 months ago

I noticed it was happening here in https://github.com/kandros/counterscale/blob/a21f6fd2f172df75268d34a65e9713fa3aaa3c23/app/analytics/query.ts#L492

image

the WHERE timestamp > ${intervalSql} is not finding _sample_interval relative to the site so it's not returned

benvinegar commented 8 months ago

Ah, yeah, I knew where the behavior was, I just wasn't sure what to do instead.

Maybe just select all sites with data within the past 90 days? (That's basically the entire data set, since CF Analytics Engine retention is 90 days at the moment.)