Closed vbessonov closed 3 years ago
I verified this roughly based on the steps above. Got a redirect to the correct to the expected resource, depending on what I had in the acquisition link.
I can also confirm that the cover links are NOT updating. Given your comments above and the fact that you changed the title of this PR, I suspect that you ar changing the scope of this PR. If so, it would be appropriate to change the scope in the description above, as well.
@tdilauro, I updated the description. If required, I can also create a new branch to avoid having cover-links
in the branch name.
@tdilauro, I updated the description. If required, I can also create a new branch to avoid having
cover-links
in the branch name.
It would probably be good to get "covers" out of the branch name (for anyone perusing the log). However, I think pushing a new branch name effectively deletes the current branch and adds a new one, which would close this PR. @leonardr or another admin for this repo might be able to rename this branch directly in GH, though.
That said, there's not much discussion to transfer to another PR, so I don't think it would be terrible to supersede this PR.
@tdilauro, I created a SQL script for fixing this issue by updating the database:
# Delete all the hyperlinks related to the specific data source.
# It will force CM to use newly imported links.
delete
from
hyperlinks as h
using
resources as r
where
h.resource_id = r.id
and r.data_source_id = 47
;
# Swipe out fulfillment info because the URL of the acquisition link has changed and it has to be updated.
update loans as l
set
fulfillment_id = null
from licensepools as lp
where
l.license_pool_id = lp.id
and lp.data_source_id = 47
;
# Delete fulfillment objects because the URL of the acquisition link has
# changed and they have to be updated
delete from licensepooldeliveries
where
data_source_id = 47
;
# Reset open_access_download_url so because the URL of the acquisition link has changed and it has to be updated.
update licensepools
set
open_access_download_url = null
where
data_source_id = 47
;
# Reset cover URLs to force them to be updated during the next import.
update editions
set
cover_full_url = null,
cover_thumbnail_url = null
where
data_source_id = 47
;
# Make sure that the new cover and acquisition links have been updated.
select
i.id,
h.data_source_id,
h.rel,
r.url
from identifiers as i
inner join hyperlinks as h on i.id = h.identifier_id
inner join resources as r on h.resource_id = r.id
where
i.identifier = 'urn:x-internet-archive:ebooks-app:item:albumdegrillesen00gand'
;
After you run the script, you can reimport the feed by running opds_import_monitor
using --force
flag.
@leonardr, do you think it's a valid approach?
Description
This PR fixes the bug related to the OPDS importer not updating acquisition.
I don't think that adding
LicensePool. reset_open_access_download_url
method is a good solution, maybe it's better to create a setter forLicensePool.best_open_access_link
property.Motivation and Context
Steps to reproduce:
How Has This Been Tested?
@tdilauro, I used the following steps for testing:
http://localhost:8080/test
which returns the same feed exceptAlbum de grilles en fer creux et fer massif
book where:1234567890
suffix to the their end.<updated>
tag's value to the current date and time in UTC.opds_import_monitor
script to reimport the updated book. Please note that the whole page whereAlbum de grilles en fer creux et fer massif
is going to be reimported (this is by design).search_index_refresh
.servers@lyrasistechnology.org
:Album de grilles en fer creux et fer massif
book and check it out.1234567890
suffix at the end.Also I just found out that the change I made doesn't fully fix the issue related to cover links not being updated. In the case of this particular feed, they remain the same. You can confirm this by looking at the loans feed at
http://localhost:6500/190150/loans
after executing step 8.It looks like that there are a couple of more changes required to fix the cover links issue:
Resource
records corresponding toHyperlink
records being deleted inMetadata.apply
that can be implemented by addingHyperlink.delete
andResource.delete
methods in the same way asLicensePoolDeliveryMechanism.delete
.Edition.cover_full_url
andEdition.cover_thumbnail_url
inMetadata.apply
ifReplacementPolicy.links
isTrue
.Edition.cover_full_url
andEdition.cover_thumbnail_url
using "new" links specified inMetadata
object. Unfortunately, I failed when I tried to implement all those steps and I think it can be implemented in a separate PR once this one is merged.Checklist: