Commit 00f79f69 authored by Michael Wagner's avatar Michael Wagner
Browse files

implemented a function which gets unique views and downloads for an orcid

parent 7bddbeb3
from zenodo_harvester import harvest_by_orcid
# -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
# HELPER FUNCTION
# -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
# -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
# CORE ZENODO HARVEST EVALUATIONS
# -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
def get_stats(creator_orcid):
"""
uses the harvest_by_orcid functionality to get downloads and views for a person
:param creator_orcid: a single ORCID as string
:return: unique downloads and unique views (multiple views/downloads in a one hour session are not counted)
"""
hits = harvest_by_orcid([creator_orcid])
unique_downloads = 0
unique_views = 0
list = hits[creator_orcid]
if not list:
print("No results found. ORCID correct?")
for l in list:
unique_downloads += l['stats']['unique_downloads']
unique_views += l['stats']['unique_views']
return unique_downloads, unique_views
# -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
# MAIN
# -_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
if __name__ == '__main__':
# creators_orcids = ['0000-0001-7430-3694', '0000-0003-0555-4128', '0000-0002-8273-6059']
creator_orcid = '0000-0003-0555-4128'
unique_downloads, unique_views = get_stats(creator_orcid)
print('unique_downloads:', unique_downloads, 'unique_views:', unique_views)
......@@ -114,7 +114,6 @@ def harvest_by_community():
"""
print("WIP")
def harvest_by_orcid(orcids, save_locally = True, slow_down=2):
"""
uses the zenodo API to request all entries for the users given by their ORCID
......@@ -155,6 +154,6 @@ def harvest_by_orcid(orcids, save_locally = True, slow_down=2):
if __name__ == '__main__':
creators_orcids = ['0000-0001-7430-3694', '0000-0003-0555-4128', '0000-0002-8273-6059']
# creators_orcids = ['0000-0003-0555-4128']
#creators_orcids = ['0000-0003-0555-4128']
hits = harvest_by_orcid(creators_orcids)
print("Done")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment