hubzero / hubzero-cms

Platform for Scientific Collaboration
https://hubzero.org
GNU General Public License v2.0
47 stars 57 forks source link

[NCN-811] Fix total resources contributed query #1709

Closed jsperhac closed 4 months ago

jsperhac commented 5 months ago

Summary

The “total” count of resources+tools created by some users is not reported correctly in the members usage plugin. The resource count and tools count are shown and the sum should be correct.

Motivation

Jira card: https://sdx-sdsc.atlassian.net/browse/NCN-811

Gerhard noticed this discrepancy in contributing users' resource counts while we were collecting resource contribution stats per user and asked that it be fixed.

The screenshot shows the members usage plugin for user "NEEDS". Notice that the "Contributions" line in Table 1 shows the value 1, whereas there are two contributions evident in Tables 2 and 3, one Tool and one Resource.

NCN-811-needs-user-screenshot

Changes Made

Query in the function first_last_contribution($authorid) was changed to ensure that author contributions were counted either if:

The problem is that the “total” count of resources+tools created by some users are not reported correctly. The resource count and tools count are shown and the sum should be correct.

To fix this, need to correct the query in public function first_last_contribution($authorid) in the plugin: core/plugins/members/usage/usage.php

Testing

The check for this is found in the script nanohub.org:/home/su-jsperhac/contributor-report/bugfix/bugfix.php which compares the existing and fixed query. The output indicates that 12 users show incorrect contribution counts when the old query is used:

contribs total 538 is wrong (correct: 539) for user gekco, with id 3482
contribs total 20 is wrong (correct: 23) for user clarksm, with id 8971
contribs total 184 is wrong (correct: 185) for user strachan, with id 13594
contribs total 38 is wrong (correct: 39) for user wang159, with id 14002
contribs total 87 is wrong (correct: 88) for user redwing, with id 14395
contribs total 26 is wrong (correct: 34) for user mmh, with id 29230
contribs total 50 is wrong (correct: 52) for user faltens, with id 29294
contribs total 0 is wrong (correct: 1) for user yao14, with id 46868
contribs total 12 is wrong (correct: 13) for user sunxingshu, with id 50809
contribs total 1 is wrong (correct: 2) for user needs, with id 83851
contribs total 17 is wrong (correct: 18) for user jferrari, with id 199067
contribs total 14 is wrong (correct: 15) for user tjsego, with id 258745
wrongTotal is: 12 

PR checklist

No hotfix should be necessary.