Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Competence Unit Research Data and Information
Labs
System
DataQuality
CRIS-zenodo-harvester
Commits
00f79f69
Commit
00f79f69
authored
Oct 26, 2021
by
Michael Wagner
Browse files
implemented a function which gets unique views and downloads for an orcid
parent
7bddbeb3
Changes
2
Hide whitespace changes
Inline
Side-by-side
harvest_utilities.py
0 → 100644
View file @
00f79f69
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
)
zenodo_harvester.py
View file @
00f79f69
...
...
@@ -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"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment