guardian / grid

The Guardian’s image management system
https://www.theguardian.com/info/developer-blog/2015/aug/12/open-sourcing-grid-image-service
Apache License 2.0
1.44k stars 119 forks source link

Conal/imagedam 1593 send to capture syndication #4244

Closed Conalb97 closed 3 months ago

Conalb97 commented 5 months ago

What does this change?

This PR introduces changes that are required as part of the BBC's integration with Capture, specifically the ability to send images to Capture. These changes have been developed on top of the existing syndication usage functionality, but have been designed to ensure backwards compatibility so that other users of the Grid are unaffected.

The syndication usage has been updated to be able to track the user that has requested an image be syndicated, via an optional 'syndicatedBy' field. Additionally, logic has been added such that if the syndication partner is "Capture", the usage status will be set as 'Pending' - otherwise the behavious remains the same.

The usage status is set to 'Pending' as the BBC are pre-empting potential failures in the delivery of images to Capture. If an image fails to be delivered to Capture then the usage status will be updated to 'Failed', if an image is successfully delivered the usage status will be updated to 'Syndicated'. Therefore, in this context, the 'Pending' usage status is being used by the BBC as an intermediate status.

In order to achieve the above workflow, a new usage status, 'Failed', has been added to 'UsageStatus' and the 'updateUsageStatus' endpoint has been added to the usages API, to provide the functionality to update the usage status for an individual usage.

These changes required an update of mappings.scala, so to deploy them an update to the Elasticsearch mapping is neccessary.

How should a reviewer test this change?

To test the changes to the syndication usage:

Make GET requests to : /usages/syndication

With the following request bodies:

{
    "data":{
        "partnerName":"Capture",
        "syndicatedBy":"<username>",
        "mediaId":"<mediaId>",
        "dateAdded":"<date>"
    }
}

{
    "data":{
        "partnerName":"BBC",
        "syndicatedBy":"<username>",
        "mediaId":"<mediaId>",
        "dateAdded":"<date>"
    }
}

{
    "data":{
        "partnerName":"BBC",
         "mediaId":"<mediaId>",
        "dateAdded":"<date>"
    }
}

To test the updateUsageStatus endpoint

Make GET requests to : /usages/status/update/<meidaId>/<usageId>

With the following request bodies:

{
    "data":
          "failed"
}

{
    "data":
          "syndicated"
}

{
    "data":
          "foo"
}

How can success be measured?

Success for the syndication usage:

  1. The request is successful and a new 'Pending' usage is added to the image specified by the mediaId - this tests that in the case of a syndication usage with a 'Capture' partner the usage status is set to 'Pending'.
  2. The request is successful and a new 'Syndicated' usage is added to the image specified by the mediaId - this tests that in the case of a syndication usage with a partner other than 'Capture' the usage status is set to 'Syndicated' (i.e. the current functionality is maintained).
  3. The request is successful and a new 'Syndicated' usage is added to the image specified by the mediaId - this tests that a successfull request can be made without including data for the new 'syndicatedBy' field in the body of the request (i.e. the current functionality is maintained).

Success for the updateUsageStatus endpoint:

  1. The request is successful and the usage status of the usage with id on the image with media id is changed to 'failed' - this tests that the endpoint can successfully update the usage status to the newly added 'failed' endpoint
  2. The request is successful and the usage status of the usage with id on the image with media id is changed to 'syndicated' - this test that the endpoint can successfully update the usage status to an existing usage status
  3. The request fails and the usage status does not change - this tests the the endpoint only accepts valid usage statuses

Who should look at this?

@guardian/digital-cms

Tested? Documented?

dblatcher commented 3 months ago

We were about to merge this, but we were unable to run the UpdateMapping script in both out TEST and PROD environments owing to previous mapping changes (e.g. https://github.com/guardian/grid/pull/3445, https://github.com/guardian/grid/pull/4056, https://github.com/guardian/grid/pull/4104, )https://github.com/guardian/grid/pull/4112) which hadn't been applied (but passed the healthcheck, unlike the mapping change in this PR). As such, we've commenced a migration in both our environments - we hope they will be complete by Monday - after which we can run the UpdateMapping script and merge this PR.

prout-bot commented 3 months ago

Seen on cropper (created by @Conalb97 and merged by @twrichards 7 minutes and 38 seconds ago) Please check your changes!

prout-bot commented 3 months ago

Seen on kahuna (created by @Conalb97 and merged by @twrichards 7 minutes and 42 seconds ago) Please check your changes!

prout-bot commented 3 months ago

Seen on usage, auth, metadata-editor (created by @Conalb97 and merged by @twrichards 7 minutes and 49 seconds ago) Please check your changes!

prout-bot commented 3 months ago

Seen on leases (created by @Conalb97 and merged by @twrichards 7 minutes and 56 seconds ago) Please check your changes!

prout-bot commented 3 months ago

Seen on leases (created by @Conalb97 and merged by @twrichards 7 minutes and 57 seconds ago) Please check your changes!

prout-bot commented 3 months ago

Seen on collections (created by @Conalb97 and merged by @twrichards 8 minutes ago) Please check your changes!

prout-bot commented 3 months ago

Seen on thrall, media-api (created by @Conalb97 and merged by @twrichards 8 minutes and 44 seconds ago) Please check your changes!

prout-bot commented 3 months ago

Seen on image-loader (created by @Conalb97 and merged by @twrichards 8 minutes and 49 seconds ago) Please check your changes!