The following snippet shows the code that selects the first X users (by uid) and inserts them into the summary table.
INSERT INTO affiliates_summary
SELECT a.user_id, SUM(aa.points), 0
FROM affiliates a, affiliates_ads aa
WHERE aa.ad_id = a.ad_id
GROUP BY a.user_id
LIMIT 50;
The updated SQL should look like or similar to the following that selects the first X users (by points descending) and inserts them into the summary table.
INSERT INTO affiliates_summary
SELECT a.user_id, SUM(aa.points) as lp, 0
FROM affiliates a, affiliates_ads aa
WHERE aa.ad_id = a.ad_id AND a.user_id != 0
GROUP BY a.user_id
ORDER BY lp DESC
LIMIT 50;
I discovered this while troubleshooting an issue where a user with the most points and a high user id was not showing up as the top affiliate.
This issue seems to affect all versions of the module (4.7.x as well as 5.x).
Submitted by: drowe (a.k.a. draco2002) http://redfinsolutions.com
Sponsored by: The Public Radio Exchange http://prx.org
| Comment | File | Size | Author |
|---|---|---|---|
| affiliates_orderby.patch | 543 bytes | draco2002 |
Comments
Comment #1
Anonymous (not verified) commentedThanks , that looks good to me.
I'll get that committed later today.
Comment #2
Anonymous (not verified) commentedComment #3
Anonymous (not verified) commented