Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with queries #46

Open
project-orcon opened this issue Sep 9, 2024 · 0 comments
Open

Issues with queries #46

project-orcon opened this issue Sep 9, 2024 · 0 comments

Comments

@project-orcon
Copy link

It looks like the queries for the top sources, maps and devices sections are wrong - they should be counting unique visits but instead because of the left outer join to events they're counting views instead

Ahoy::Visit Count (0.8ms)  SELECT COUNT(*) AS "count_all", "ahoy_visits"."country" AS "ahoy_visits_country" FROM "ahoy_visits" LEFT OUTER JOIN "ahoy_events" ON "ahoy_events"."visit_id" = "ahoy_visits"."id" WHERE ("ahoy_visits"."started_at" > '2024-08-10 04:56:47.803227' AND "ahoy_visits"."started_at" < '2024-09-09 04:56:47.803276') AND ("ahoy_events"."time" > '2024-08-10 04:56:47.803519' AND "ahoy_events"."time" < '2024-09-09 04:56:47.803567') GROUP BY "ahoy_visits"."country"
  Ahoy::Visit Load (3.7ms)  SELECT browser as label, count(browser) as count, sum(count(browser)) over() as total_count FROM "ahoy_visits" LEFT OUTER JOIN "ahoy_events" ON "ahoy_events"."visit_id" = "ahoy_visits"."id" WHERE ("ahoy_visits"."started_at" > '2024-08-10 04:56:47.801767' AND "ahoy_visits"."started_at" < '2024-09-09 04:56:47.801824') AND ("ahoy_events"."time" > '2024-08-10 04:56:47.802147' AND "ahoy_events"."time" < '2024-09-09 04:56:47.802194') GROUP BY "ahoy_visits"."browser" ORDER BY count(browser) desc LIMIT $1 

this query AhoyCaptain.visit.joins(shared_context.join_sources) should have .distinct on it

also it it would be good in the UX if instead of displaying 'visitors' in each of these sections it displayed 'visits' & for top pages it displayed 'views'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant