Skip to content

Commit

Permalink
Merge pull request #199 from Tehsurfer/monthly-stats-fix
Browse files Browse the repository at this point in the history
Fix a dictionary evaluation error in monthly stats
  • Loading branch information
Tehsurfer authored Mar 5, 2024
2 parents 9ab8100 + 659d151 commit 258b8b4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions scripts/monthly_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,14 @@ def create_user_download_object(self, dataset_details_object, download_stats):
for contributor in dataset['contributors']:
orcid_id = contributor['orcid']

# Add the download info with an orcid id as a key
if orcid_id not in users.keys():
users[orcid_id] = {}
users[orcid_id]['datasets'] = downloadInfo
else:
users[orcid_id]['datasets'] += downloadInfo
if orcid_id is not None:
# Add the download info with an orcid id as a key
if orcid_id not in users.keys():
users[orcid_id] = {}
users[orcid_id]['datasets'] = downloadInfo
else:
# Must to a dictionary 'get' below, as using += mutates the dictionary
users[orcid_id]['datasets'] = users.get(orcid_id)['datasets'] + downloadInfo

return users

Expand Down

0 comments on commit 258b8b4

Please sign in to comment.