Skip to content

GitLab Next

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • GitLab GitLab
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 39,512
    • Issues 39,512
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 1,222
    • Merge requests 1,222
  • Requirements
    • Requirements
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
    • Value stream
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GitLab.org
  • GitLabGitLab
  • Merge requests
  • !35210

You need to sign in or sign up before continuing.
Merged
Created Jun 24, 2020 by Patrick Derichs@pd-gitlabContributor2 of 13 tasks completed2/13 tasks

Add state events to API

  • Overview 69
  • Commits 4
  • Pipelines 21
  • Changes 10

What does this MR do?

Adds an API to query resource state events.

MR to add menu item for documentation: gitlab-docs!975 (merged)

Queries

Sample query:

explain analyze SELECT "resource_state_events".* FROM "resource_state_events" WHERE "resource_state_events"."issue_id" = 520 order by id offset 0 limit 100

Explain analyze:

Limit  (cost=0.29..4.13 rows=100 width=84) (actual time=0.017..0.059 rows=100 loops=1)
  ->  Index Scan using resource_state_events_pkey on resource_state_events  (cost=0.29..769.76 rows=20009 width=84) (actual time=0.017..0.053 rows=100 loops=1)
        Filter: (issue_id = 520)
        Rows Removed by Filter: 18
Planning time: 0.085 ms
Execution time: 0.076 ms

Test in rails console:

[1] pry(main)> i = Issue.find(520)
  Issue Load (5.4ms)  SELECT "issues".* FROM "issues" WHERE "issues"."id" = 520 LIMIT 1
  Project Load (10.0ms)  SELECT "projects".* FROM "projects" WHERE "projects"."id" = 8 LIMIT 1
  Route Load (1.7ms)  SELECT "routes".* FROM "routes" WHERE "routes"."source_id" = 8 AND "routes"."source_type" = 'Project' LIMIT 1
=> #<Issue id:520 h5bp/html5-boilerplate#69>
[2] pry(main)> ResourceStateEventFinder.new(User.find(1), i).execute.order(:id).page(1).per(100)
  User Load (12.8ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 LIMIT 1
  ProjectFeature Load (6.2ms)  SELECT "project_features".* FROM "project_features" WHERE "project_features"."project_id" = 8 LIMIT 1
  ApplicationSetting Load (2.2ms)  SELECT "application_settings".* FROM "application_settings" ORDER BY "application_settings"."id" DESC LIMIT 1
  ResourceStateEvent Load (3.2ms)  SELECT "resource_state_events".* FROM "resource_state_events" WHERE "resource_state_events"."issue_id" = 520 ORDER BY "resource_state_events"."id" ASC LIMIT 100 OFFSET 0
  User Load (0.6ms)  SELECT "users".* FROM "users" WHERE "users"."id" IN (1, 2)

Screenshots

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 Jul 02, 2020 by John Hope
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: add-state-events-api-pd

Enable Gitpod?

To use Gitpod you must first enable the feature in the integrations section of your user preferences.

Cancel Enable Gitpod