Create devops adoption measurements
What does this MR do?
This MR implements the snapshots relation for a segment. A snapshot contains several boolean flags recording which devops features are used by the segment. A segment might consist of several groups.
The MR includes:
- Moving all models and tests to EE (mistake from a previous MR), this is an EE feature.
- Add the
Snapshot
model - Expose the latest
Snapshot
record in GraphQL - Preloading logic for taking the latest snapshot, avoiding N+1.
- GraphQL API change (feature is not in used) to return array of groups (we allow maximum 20 groups so it's safe to load them at once)
How to test it:
- Generate data
FILTER=devops_adoption rake db:seed_fu
- Log in as admin
- Go to graphql explorer: http://localhost:3000/-/graphql-explorer
- Run the query
query devopsAdoption {
devopsAdoptionSegments {
nodes{
id
name
groups {
id
name
webUrl
}
latestSnapshot {
issueOpened
mergeRequestOpened
mergeRequestApproved
runnerConfigured
pipelineSucceeded
deploySucceeded
securityScanSucceeded
recordedAt
}
}
}
}
DB Query
SELECT "analytics_devops_adoption_snapshots".*
FROM "analytics_devops_adoption_snapshots"
INNER JOIN
(SELECT DISTINCT FIRST_VALUE(id) OVER (PARTITION BY segment_id
ORDER BY recorded_at DESC) AS id
FROM "analytics_devops_adoption_snapshots"
WHERE "analytics_devops_adoption_snapshots"."segment_id" IN (11, 12)) latest_snapshots ON latest_snapshots.id = analytics_devops_adoption_snapshots.id
Plan: https://explain.depesz.com/s/xC4E
We'll look up maximum 20 segment_ids.
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
-
Label as security and @ mention @gitlab-com/gl-security/appsec
-
The MR includes necessary changes to maintain consistency between UI, API, email, or other methods -
Security reports checked/validated by a reviewer from the AppSec team
Edited by Adam Hegyi