Skip to content

insights: support single snapshot point for compute type insights

Administrator requested to merge insights/compute-type-single-point into main

Created by: leonore

closes #37868 (closed)

we implement single data point for current day by:

  • enqueuing a snapshot
  • making backfilling/recording impossible reused insight enqueuer functions by exporting them.

NOTE: with the current state of our UI, groupBy options are not being propagated from the insight card, which means that if the insight is updated there and it finds matching series in the database, we will find ourselves with multiple data points after update.

Test plan

Existing unit tests ran correctly.

Checked mutations for:

  • a scoped insight
  • an insight over all repositories
  • updating an insight over all repositories and passing groupBy options (see note on why this will not work from the UI)
mutation computeType {
    createLineChartSearchInsight (input: {
        options: {
            title: "all repos to update"
        },
        dashboards: [
          "ZGFzaGJvYXJkOnsiSWRUeXBlIjoiY3VzdG9tIiwiQXJnIjoxfQ==",
        ]
        dataSeries: [{
            query: "log15   ",
            options: {
                label: "log15",
                lineColor: "var(--oc-grape-7)"
        },
        repositoryScope: {
          repositories: [],
        },
        timeScope: {
           stepInterval: {
                  unit: MONTH,
                  value: 1
            }
        },
        groupBy: REPO
        }]
    })
    {
      view {
          id,
          dataSeriesDefinitions {
              ... on SearchInsightDataSeriesDefinition {
                  seriesId,
                  query,
                  repositoryScope {
                      repositories
                  }
                  timeScope {
                  ... on InsightIntervalTimeScope {
                          unit,
                          value
                      }
                  },
                  groupBy
              }
          }
    }
      
}
}

mutation updateLineChartSearchInsight {
  updateLineChartSearchInsight(id: "aW5zaWdodF92aWV3OiIyQlpXa05QeGxFTkVoMnFITjlqZEFheVRaODUi", input: {
        presentationOptions: {
           title: "renamed from graphql api!"
        },
        viewControls: {
          seriesDisplayOptions: {},
          filters: {},
        },
        dataSeries: [{
            query: "log15   ",
            options: {
                label: "log15",
                lineColor: "var(--oc-grape-7)"
        },
        repositoryScope: {
          repositories: [],
        },
        timeScope: {
           stepInterval: {
                  unit: MONTH,
                  value: 1
            }
        },
        groupBy: REPO
        }]
    }) {
    view {
      ...InsightDataNode
    }
  }
}

fragment InsightDataNode on InsightView {
  id
  dataSeries {
    ...InsightDataSeries
    __typename
  }
  __typename
}

Merge request reports

Loading