[License Compliance MR Widget Extension] - Backend - Additional API endpoint for License Compliance Merge Request Widget (collapsed data state)

The License Compliance Merge Request Widget is currently migrated to use the new MR Widget extension.

More about this here.

In its current state License Compliance MR Widget will make one request to receive all of its data.

existing endpoint

url example link
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/$MR_ID/license_scanning_reports !75341 (merged)

Response Structure:

{
  "new_licenses": [
    ...list_of_new_licenses
  ],
  "existing_licenses": [
    ...list_of_existing_licenses
  ],
  "removed_licenses": [
    ...list_of_removed_licenses
  ]
}

This endpoint will remain untouched. But the Payload over the wire can get pretty big potentially. As a performance Improvement, the MR Widget extension requires an additional endpoint to only represent the data used in the collapsed state of the MR Widget. To reduce the network payload when the user is not uncollapsing the License Compliance MR Widget, making the MR page faster.

additional endpoint

url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/$MR_ID/license_scanning_reports_collapsed

Response Structure:

{
  "new_licenses": $integer_value_of_new_licenses_found,
  "existing_licenses": $integer_value_of_existing_licenses_found,
  "removed_licenses": $integer_value_of_removed_licenses_found,
}

Implementation plan

  1. in EE::Projects::MergeRequestsController create a new action license_scanning_reports_collapsed, make it similar to license_scanning_reports action.
  2. Inherit a new compare service from CompareLicenseScanningReportsService and change the serializer to a new serializer (example name LicenseScanningReportsCollapsedComparerEntity).
  3. expose new_licenses, existing_licenses, removed_licenses as entity.new_licencese.count and so on. In this case the entity is an instance of Gitlab::Ci::Reports::LicenseScanning::ReportsComparer.
  4. Test new action, compare service and serializer

Testing

SET is to update the License Widget Merge Request widget End to End/UI test ( https://gitlab.com/gitlab-org/gitlab/-/blob/master/qa/qa/specs/features/ee/browser_ui/13_secure/merge_request_license_widget_spec.rb ) adding selectors to the widget where needed.

Edited by -