-
Notifications
You must be signed in to change notification settings - Fork 7
feat: ebook record dedup #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4993e33
to
34a2e9f
Compare
rero_ebooks/api.py
Outdated
): | ||
"""Create a new ebook record.""" | ||
assert cls.minter | ||
if delete_pid and data.get('pid'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not assert not data.get('pid')
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accepted your proposition, done
rero_ebooks/api.py
Outdated
assert cls.minter | ||
if delete_pid and data.get('pid'): | ||
del (data['pid']) | ||
if not id_: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
problem copy and paste from reroils_data, fixed
rero_ebooks/api.py
Outdated
except PIDDoesNotExistError: | ||
return None | ||
|
||
@staticmethod |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternative implementation (to be checked):
import copy
@staticmethod
def _merge(new_record, record):
"""Merge new and old electronic_location_and_access fields."""
field = 'electronic_location_and_access'
new_e_r = new_record.get(field)
old_e_r = record.get(field)
for e_r in old_e_r:
# check if already exists!
if e_r not in new_e_r:
new_e_r.append(copy.deepcopy(e_r))
new_record['__order__'].insert(
new_record['__order__'].index(field), field
)
return new_record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accepted your proposition, done
rero_ebooks/api.py
Outdated
|
||
@staticmethod | ||
def _merge(new_record, record): | ||
"""Merge new and old records.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No realy merge record but only electronic_location_and_access
|
||
|
||
@pytest.yield_fixture() | ||
def cdf_record(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does CDF means?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cdf = la-chaux-de-fonds, comments added to the tests
tests/api/conftest.py
Outdated
|
||
@pytest.yield_fixture() | ||
def mv_record(): | ||
"""CDF record.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MV record instead? What is MV?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MV: mediatheque-valais, comments added to the tests
tests/api/test_api.py
Outdated
assert merged_record_status == 'updated' | ||
ela = merged_record['electronic_location_and_access'] | ||
assert len(ela) == 2 | ||
first_856 = ela[0]['uniform_resource_identifier'][0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do not use 856 here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
used uri instead of 856, done
Signed-off-by: Aly Badr <aly.badr@rero.ch>
34a2e9f
to
d711ece
Compare
How to test:
dojson -l marcxml -i data/ebooks.xml do cantookmarc21 | invenio records create_else_update --vendor cantook
Signed-off-by: Aly Badr aly.badr@rero.ch
Co-authored-by: Gianni Pante gianni.pante@rero.ch