Skip to content

Add filtering by recorded at date to measurements

Adam Hegyi requested to merge 268000-extend-graphql-measurements-api into master

What does this MR do?

This change adds filtering capabilities by recorded at to instance statistics measurements GraphQL api.

To get data, make sure you run the seed file:

FILTER=instance_statistics rake db:seed_fu

Testing:

Log in to your local GDK and then navigate to: http://localhost:3000/-/graphql-explorer

Assuming that you're admin, you should be able to run the queries.

GraphQL query:

query getMeasurements {
  instanceStatisticsMeasurements(identifier:PROJECTS, recordedAfter:"2020-01-01", recordedBefore:"2020-11-01") {
    nodes {
      identifier
      count
      recordedAt
      
    }
  }
}

Database

Example query:

The recorded_at column is already covered by an index.

SELECT "analytics_instance_statistics_measurements".* FROM "analytics_instance_statistics_measurements" WHERE "analytics_instance_statistics_measurements"."recorded_at" >= '2019-12-31 23:00:00' AND "analytics_instance_statistics_measurements"."recorded_at" <= '2021-12-31 23:00:00' AND "analytics_instance_statistics_measurements"."identifier" = 1 ORDER BY "analytics_instance_statistics_measurements"."recorded_at" DESC, "analytics_instance_statistics_measurements"."id" DESC LIMIT 100;

Plan

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 #268000 (closed)

Edited by Adam Hegyi

Merge request reports

Loading