Repository navigation
Add rcmds_received to user methods - #646
Conversation
|
Please fix the conflicts. |
a18fea5 to
57e6559
Compare
|
Thanks, rebased. |
hxdimpf
left a comment
There was a problem hiding this comment.
Looks good to me. The field is useful, the query matches the rest of the method (one query for all requested users, 0 for users without recommendations), and the docs are clear.
Tested on the VM (this commit on the current master), OCDE and OCPL on MariaDB 10.11 and 10.0, with the suite from #653, read-only and --write: 0 failures. users/by_username with rcmds_received works.
One observation, not a blocker: the description says the number "is equal to the sum of recommendations" of the user's caches. That holds only while the stored counters match the rows. caches/geocaches reads recommendations from the counter (stat_caches.toprating on OCDE, caches.topratings on OCPL), while this field counts the cache_rating rows.
- On the OCPL 2018 devel dump, 16 of 56,154 published caches have a counter that differs from their rows (133,948 by counter vs 133,960 by rows).
- On our OCDE dev database,
cache_ratingis empty but the counters were kept, so a user getsrcmds_received0 whilerecommendationssums to 1. - Counting the rows is arguably the more correct number. The docs in
users/userdon't promise equality, so nothing needs to change. If you want the two to always agree, summing the same counter would do it.
Nit: the other queries in this method quote and escape the user IDs (array_map('\okapi\core\Db::escape_string', …)); this one implodes them as they are. They come from the database as integers, so it's safe; it's only a matter of consistency.
57e6559 to
097002e
Compare
Sync with opencaching/okapi: safe random functions (opencaching#652), rcmds_received (opencaching#646)
Entries in `etc/changes.xml` for the changes merged since the last changelog PR (#665) that matter to client developers or site admins: #649, #654, #646, #651, #682, #680, #666, #676, #672, #671, #667. Version numbers and times were filled in by `etc/update_changes.php`. #652 has no visible change for clients, so it has no entry.
Adds a
rcmds_receivedfield toservices/users/users.It returns the number of recommendations received for the caches the user currently owns. It only counts caches that OKAPI returns (Available, Temporarily unavailable and Archived), so it is equal to the sum of
recommendationsof the user's caches inservices/caches/geocaches. Both OCPL and OCDE store recommendations incache_rating, so the query is the same for both.ownerlogs.php), and it counts caches with any status. OKAPI can return a lower number if the user has unpublished or locked caches.The number can already be counted from the recommendations shown on each cache page, on both sites and in OKAPI. This field just adds them up.
Adopted caches count for the new owner, the same as on both sites.
Testing
Tested on local OCPL and OCDE instances with
users,user,by_internal_idsandby_usernames. On OCPL, compared the numbers with the sum ofrecommendationsof the user's caches. On OCDE, added recommendations for caches with different statuses (including unpublished and archived) and checked which were counted.