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: Topic referrals by user were wrong #2999

Merged
merged 1 commit into from
Nov 25, 2014

Conversation

riking
Copy link
Contributor

@riking riking commented Nov 24, 2014

This commit fixes the "Top Referrers (Last 30 Days)" display in the
Admin panel, specifically the "Topics" column. Previously, the Clicks
and Topics column of the table would be identical. This commit fixes
that by counting the number of different topics that were referred to.

Raw SQL queries are used because it was easier for me to write, and it
was easier to extract the data needed to pass on from the first query to
the second (the user ids).

The data shuffling after the queries shouldn't be too bad, I just needed
to get it into the report format. Not sure how I would eliminate the
.sort_by at the end without having to preserve order everywhere, which
is not a guarantee I am willing to rely on. (The second query is
unordered for this reason.)


Fixes discrepancy noticed here and since degraded https://meta.discourse.org/t/top-referrers-difference-between-views-and-topics/15812/6

Before | After

image

@discoursebot
Copy link

You've signed the CLA, riking. Thank you! This pull request is ready for review.

@riking
Copy link
Contributor Author

riking commented Nov 24, 2014

While checking the build error, I discovered that the tests were extremely bad. So I rewrote the integration test, and realized that I missed that another report had the same problem. I think that the same solution can be used for the original change, too, reducing the diff significantly.

@riking
Copy link
Contributor Author

riking commented Nov 24, 2014

Yup, that was easier. New before/after:

image

@ZogStriP
Copy link
Member

👍 Will merge once rebased ;)

Due to what seems to be a bug in ActiveRecord, the distinct: true option
is not recognized on counts with string column names. This commit fixes
that by moving the DISTINCT into the count string.

For robustness, the integration spec for IncomingLinksReport was
rewritten to be an actual integration spec, running the actual interface
on actual fake data.
@riking riking force-pushed the fix_top_referrers_topic_count branch from ce5c5bf to 728e8a2 Compare November 24, 2014 20:17
@riking
Copy link
Contributor Author

riking commented Nov 25, 2014

@ZogStriP Rebased :)

ZogStriP added a commit that referenced this pull request Nov 25, 2014
FIX: Topic referrals by user were wrong
@ZogStriP ZogStriP merged commit 0588292 into discourse:master Nov 25, 2014
@ZogStriP
Copy link
Member

❤️

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

Successfully merging this pull request may close these issues.

3 participants