dlcs / protagonist

MIT License
7 stars 2 forks source link

Convert existing ‘IOP’,‘ThumbnailPolicy’ and ‘DeliveryChannel’ values from Images table into ImageDeliveryChannels table #620

Closed tomcrane closed 6 months ago

tomcrane commented 1 year ago

Donald:

At this stage we have duplicate records in IOP/ThumbailPolicy and ImageDeliveryChannels. This should make engine implementation easier.

tomcrane commented 1 year ago

Could this be a DB migration? Or a one-off script?

tomcrane commented 10 months ago

This migration can be run often and repeatedly as it doesn't modify the source data (a later cleanup can remove those fields).

Acceptance Criteria

tomcrane commented 10 months ago

This script / migration will need to create all the distinct policies for thumbs it encounters, so that it can create an entry in the linking table. E.g., for Wellcome, there are (at a guess) 3 different policies in use. After running, there will be three entries under here, rather than one:

{
    "@context": "https://dlcs.github.io/vocab/context/future.json",
    "@id": "https://api.dlcs.digirati.io/customers/2/deliveryChannelPolicies/thumbnail",
    "@type": "Collection",
    "totalItems": 1,
    "member": [
        {
            "@id": "https://api.dlcs.digirati.io/customers/2/deliveryChannelPolicies/thumbnail/standard",
            "@type": "vocab:DeliveryChannelPolicy",
            "id": "standard",
            "displayName": "Standard thumbnail sizes",
            "channel": "thumbnail",
            "policyData": "[ \"!1024,1024\", \"!400,400\", \"!200,200\", \"!100,100\" ]",
            "policyModified": "2023-09-19T15:36:58.6023600Z"
        }
    ]
}

i.e., the migration might have created 50m linking rows but on the way it only needed to make 3 policy rows. Although the default policy was probably created before processing the 50m.

tomcrane commented 10 months ago

Thinking about this task after writing https://github.com/dlcs/protagonist/blob/delivery-channel-sequence/docs/delivery-channel-switchover/index.md

That talks about emulating the wcDeliveryChannels, ImageOptimisationPolicy and ThumbnailPolicy fields by converting them at the API boundary into the new model internally in the DLCS, so that existing callers (mainly Wellcome) can switch over seamlessly. That includes calling the API with no values for these (which is the norm) - the dc relationships still get created from defaults.

That approach could be used to implement this issue; we do the conversion by calling the same conversion, per asset.

⚠️ This work starts to collide with the migration of shared services and other DLCS instances.

However, use of IOP/thumbnailPolicy is rare/nonexistent and this will be a deprecated feature.

tomcrane commented 10 months ago

Closing https://github.com/dlcs/protagonist/issues/630 as it is a subset of this issue. Part of this issue (620) is to convert implied/default thumbnail delivery channels into explicit links to thumbnail deliverychannelpolicy(ies), using the correct syntax, and not doing what #630 proposed.

tomcrane commented 10 months ago

Need to make sure that the necessary DCP entries exist before creating all the linking policies.

Also remember that only Wellcome is running protagonist and has the v1 deliveryChannels impl.