Skip to content

Expose projects with integration overrides

Luke Duncalfe requested to merge 218252-backend into master

What does this MR do?

This MR exposes a JSON endpoint of projects that are using different integration settings other than what has been set on the instance admin-level. A frontend MR will later consume the data #218252 (closed).

Walking through the QA steps should help to explain the feature 🙂.

QA

  1. Visit your instance admin's integration settings (/admin/application_settings/integrations), and configure the Campfire integration (we use Campfire in this example because it's a simple integration; it requires a token to be provided - just enter anything).
  2. Visit a project's Campfire integration settings (/<project-full-path>/-/services/campfire/edit) and change the drop-down to Use custom settings. Save the integration (you don't need to change anything else in the form).
  3. Visit the JSON endpoint for Campfire overrides (/admin/application_settings/integrations/campfire/overrides.json) and the project should appear in the list.
  4. Edit the project's Campfire integration again, this time change the drop-down to Use default settings. Save the integration.
  5. Visit the JSON endpoint for Campfire overrides and the project should not appear.

Example JSON output

[
  {
    "avatar_url": null,
    "full_name": "Administrator / test",
    "name": "test",
    "full_path": "/root/test"
  }
]

Example queries

We're using ConfluenceService here as the example integration type.

The queries produced by changes in Admin::IntegrationsController#overrides are:

The paginator count query (link to #database-lab result):

SELECT
   COUNT(*) 
FROM
   (
      SELECT
         1 AS one 
      FROM
         "projects" 
         INNER JOIN
            "integrations" 
            ON "integrations"."project_id" = "projects"."id" 
      WHERE
         "integrations"."type" = 'ConfluenceService' 
         AND "integrations"."active" = TRUE 
         AND "integrations"."inherit_from_id" IS NULL LIMIT 10001
   )
   subquery_for_count

The results query (link to #database-lab result)::

SELECT
   "projects".* 
FROM
   "projects" 
   INNER JOIN
      "integrations" 
      ON "integrations"."project_id" = "projects"."id" 
WHERE
   "integrations"."type" = 'ConfluenceService' 
   AND "integrations"."active" = TRUE 
   AND "integrations"."inherit_from_id" IS NULL 
ORDER BY
   "projects"."id" ASC LIMIT 20 OFFSET 0

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Related to #218252 (closed)

Edited by Luke Duncalfe

Merge request reports

Loading