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

Fix pagination in getAllCountsByColumn #123

Merged
merged 3 commits into from
Dec 12, 2024
Merged

Conversation

benvinegar
Copy link
Owner

Fixes #122

I realize now getAllCountsByColumn had flawed logic; it was trying to get the top N rows, but also trying to simultaneously get data for visitors and views which doesn't work because that needs 2x the rows, and the count properties might not return in the same order either.

So instead this makes two queries:

  1. First, queries the column by visitor count. This first query determines the order (so the rows are sorted by visitor count, not view count).

  2. Then, make another query by view count, using a WHERE $column IN ($columnVal1, $columnVal1, ... $columnVal1) clause from the results of the first query.

This is slower of course, but it seems unavoidable the way Analytics Engine works.

Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 81.08%. Comparing base (db24a2b) to head (47af390).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #123      +/-   ##
==========================================
+ Coverage   80.93%   81.08%   +0.14%     
==========================================
  Files          32       32              
  Lines        2271     2289      +18     
  Branches      250      253       +3     
==========================================
+ Hits         1838     1856      +18     
  Misses        425      425              
  Partials        8        8              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@benvinegar benvinegar merged commit da2aecb into main Dec 12, 2024
3 checks passed
@benvinegar benvinegar deleted the fix-all-count-pagination branch December 12, 2024 19:08
benvinegar added a commit that referenced this pull request Dec 20, 2024
* getAllCounts needs two separate queries

* Fix test

* Fix remaining tests
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

Successfully merging this pull request may close these issues.

Pagination doesn't appear to be working for path or referrer
1 participant