Skip to content

Models for Devops Adoption segment configuration

Adam Hegyi requested to merge 262395-models-for-devops-adoption-segments into master

What does this MR do?

This MR sets up the models and database tables for configuring devops adoption segment.

A segment (maximum 20 segments) exists on the instance level and it can contain maximum 20 groups or projects. These segments will be periodically probed to collect various metrics about the devops adoption.

Example

Create a segment called "GitLab" which contains the following groups:

  • gitlab-org
  • gitlab-com

A periodical process (not part of this MR) will look into the configured groups and stores metrics. Examples:

  • Was there an issue created in the last 30 days? (store boolean flag: the segment adopted issues)
  • Was there an epic created in the last 30 days? (store boolean flag: the segment adopted epics)
  • ...

More info and mockups: #235421 (closed)

Database

Modeling the selection:

image

segments

Migrations

up

== 20201021085007 CreateAnalyticsDevopsAdoptionSegments: migrating ============
-- create_table(:analytics_devops_adoption_segments, {:if_not_exists=>true})
   -> 0.0257s
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0006s
-- current_schema()
   -> 0.0006s
-- execute("SET statement_timeout TO 0")
   -> 0.0005s
-- execute("ALTER TABLE dast_site_profiles VALIDATE CONSTRAINT check_6cfab17b48;")
   -> 0.0008s
-- execute("RESET ALL")
   -> 0.0004s
== 20201021085007 CreateAnalyticsDevopsAdoptionSegments: migrated (0.0385s) ===

== 20201021102554 CreateAnalyticsDevopsAdoptionSegmentSelections: migrating ===
-- create_table(:analytics_devops_adoption_segment_selections)
   -> 0.0323s
== 20201021102554 CreateAnalyticsDevopsAdoptionSegmentSelections: migrated (0.0324s)

== 20201021105347 AddForeignKeyProjectIdToSegmentSelection: migrating =========
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:analytics_devops_adoption_segment_selections)
   -> 0.0069s
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections\nADD CONSTRAINT fk_f1472b95f3\nFOREIGN KEY (project_id)\nREFERENCES projects (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0027s
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections VALIDATE CONSTRAINT fk_f1472b95f3;")
   -> 0.0078s
== 20201021105347 AddForeignKeyProjectIdToSegmentSelection: migrated (0.0266s)

== 20201021105600 AddForeignKeyGroupIdToSegmentSelection: migrating ===========
-- transaction_open?()
   -> 0.0000s
-- foreign_keys(:analytics_devops_adoption_segment_selections)
   -> 0.0057s
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections\nADD CONSTRAINT fk_ded7fe0344\nFOREIGN KEY (group_id)\nREFERENCES namespaces (id)\nON DELETE CASCADE\nNOT VALID;\n")
   -> 0.0030s
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections VALIDATE CONSTRAINT fk_ded7fe0344;")
   -> 0.0032s
== 20201021105600 AddForeignKeyGroupIdToSegmentSelection: migrated (0.0179s) ==

== 20201021105959 AddCheckConstraintToSegmentSelection: migrating =============
-- transaction_open?()
   -> 0.0000s
-- current_schema()
   -> 0.0006s
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections\nADD CONSTRAINT segment_selection_project_id_or_group_id_required\nCHECK ( (project_id != NULL AND group_id IS NULL) OR (group_id != NULL AND project_id IS NULL) )\nNOT VALID;\n")
   -> 0.0010s
-- current_schema()
   -> 0.0006s
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections VALIDATE CONSTRAINT segment_selection_project_id_or_group_id_required;")
   -> 0.0016s
== 20201021105959 AddCheckConstraintToSegmentSelection: migrated (0.0125s) ====

down

== 20201021105959 AddCheckConstraintToSegmentSelection: reverting =============
-- execute("ALTER TABLE analytics_devops_adoption_segment_selections\nDROP CONSTRAINT IF EXISTS segment_selection_project_id_or_group_id_required\n")
   -> 0.0007s
== 20201021105959 AddCheckConstraintToSegmentSelection: reverted (0.0040s) ====

== 20201021105600 AddForeignKeyGroupIdToSegmentSelection: reverting ===========
-- remove_foreign_key(:analytics_devops_adoption_segment_selections, {:column=>:group_id})
   -> 0.0038s
== 20201021105600 AddForeignKeyGroupIdToSegmentSelection: reverted (0.0068s) ==

== 20201021105347 AddForeignKeyProjectIdToSegmentSelection: reverting =========
-- remove_foreign_key(:analytics_devops_adoption_segment_selections, {:column=>:project_id})
   -> 0.0043s
== 20201021105347 AddForeignKeyProjectIdToSegmentSelection: reverted (0.0119s)

== 20201021102554 CreateAnalyticsDevopsAdoptionSegmentSelections: reverting ===
-- drop_table(:analytics_devops_adoption_segment_selections)
   -> 0.0017s
== 20201021102554 CreateAnalyticsDevopsAdoptionSegmentSelections: reverted (0.0032s)

== 20201021085007 CreateAnalyticsDevopsAdoptionSegments: reverting ============
-- drop_table(:analytics_devops_adoption_segments)
   -> 0.0033s
== 20201021085007 CreateAnalyticsDevopsAdoptionSegments: reverted (0.0034s) ===

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

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

Related to #262395 (closed)

Edited by Mayra Cabrera

Merge request reports