Skip to content
Snippets Groups Projects
Commit 29e01668 authored by Adam Hegyi's avatar Adam Hegyi :coffee:
Browse files

Rename InstanceStatistics to UsageTrend

This change renames the InstanceStatistics feature to UsageTrends in the
codebase. Note: the UI strings have been already changed in an earlier
commit.
parent 258c8f0b
No related branches found
No related tags found
No related merge requests found
Showing
with 167 additions and 44 deletions
<script>
import { TODAY, TOTAL_DAYS_TO_SHOW, START_DATE } from '../constants';
import ChartsConfig from './charts_config';
import InstanceCounts from './instance_counts.vue';
import InstanceStatisticsCountChart from './instance_statistics_count_chart.vue';
import ProjectsAndGroupsChart from './projects_and_groups_chart.vue';
import UsageCounts from './usage_counts.vue';
import UsageTrendsCountChart from './usage_trends_count_chart.vue';
import UsersChart from './users_chart.vue';
 
export default {
name: 'InstanceStatisticsApp',
name: 'UsageTrendsApp',
components: {
InstanceCounts,
InstanceStatisticsCountChart,
UsageCounts,
UsageTrendsCountChart,
UsersChart,
ProjectsAndGroupsChart,
},
Loading
Loading
@@ -23,7 +23,7 @@ export default {
 
<template>
<div>
<instance-counts />
<usage-counts />
<users-chart
:start-date="$options.START_DATE"
:end-date="$options.TODAY"
Loading
Loading
@@ -34,7 +34,7 @@ export default {
:end-date="$options.TODAY"
:total-data-points="$options.TOTAL_DAYS_TO_SHOW"
/>
<instance-statistics-count-chart
<usage-trends-count-chart
v-for="chartOptions in $options.configs"
:key="chartOptions.chartTitle"
:queries="chartOptions.queries"
Loading
Loading
import { s__, __, sprintf } from '~/locale';
import query from '../graphql/queries/instance_count.query.graphql';
import query from '../graphql/queries/usage_count.query.graphql';
 
const noDataMessage = s__('InstanceStatistics|No data available.');
const noDataMessage = s__('UsageTrends|No data available.');
 
export default [
{
loadChartError: sprintf(
s__(
'InstanceStatistics|Could not load the pipelines chart. Please refresh the page to try again.',
),
s__('UsageTrends|Could not load the pipelines chart. Please refresh the page to try again.'),
),
noDataMessage,
chartTitle: s__('InstanceStatistics|Pipelines'),
yAxisTitle: s__('InstanceStatistics|Items'),
xAxisTitle: s__('InstanceStatistics|Month'),
chartTitle: s__('UsageTrends|Pipelines'),
yAxisTitle: s__('UsageTrends|Items'),
xAxisTitle: s__('UsageTrends|Month'),
queries: [
{
query,
title: s__('InstanceStatistics|Pipelines total'),
title: s__('UsageTrends|Pipelines total'),
identifier: 'PIPELINES',
loadError: sprintf(
s__('InstanceStatistics|There was an error fetching the total pipelines'),
),
loadError: sprintf(s__('UsageTrends|There was an error fetching the total pipelines')),
},
{
query,
title: s__('InstanceStatistics|Pipelines succeeded'),
title: s__('UsageTrends|Pipelines succeeded'),
identifier: 'PIPELINES_SUCCEEDED',
loadError: sprintf(
s__('InstanceStatistics|There was an error fetching the successful pipelines'),
),
loadError: sprintf(s__('UsageTrends|There was an error fetching the successful pipelines')),
},
{
query,
title: s__('InstanceStatistics|Pipelines failed'),
title: s__('UsageTrends|Pipelines failed'),
identifier: 'PIPELINES_FAILED',
loadError: sprintf(
s__('InstanceStatistics|There was an error fetching the failed pipelines'),
),
loadError: sprintf(s__('UsageTrends|There was an error fetching the failed pipelines')),
},
{
query,
title: s__('InstanceStatistics|Pipelines canceled'),
title: s__('UsageTrends|Pipelines canceled'),
identifier: 'PIPELINES_CANCELED',
loadError: sprintf(
s__('InstanceStatistics|There was an error fetching the cancelled pipelines'),
),
loadError: sprintf(s__('UsageTrends|There was an error fetching the cancelled pipelines')),
},
{
query,
title: s__('InstanceStatistics|Pipelines skipped'),
title: s__('UsageTrends|Pipelines skipped'),
identifier: 'PIPELINES_SKIPPED',
loadError: sprintf(
s__('InstanceStatistics|There was an error fetching the skipped pipelines'),
),
loadError: sprintf(s__('UsageTrends|There was an error fetching the skipped pipelines')),
},
],
},
{
loadChartError: sprintf(
s__(
'InstanceStatistics|Could not load the issues and merge requests chart. Please refresh the page to try again.',
'UsageTrends|Could not load the issues and merge requests chart. Please refresh the page to try again.',
),
),
noDataMessage,
chartTitle: s__('InstanceStatistics|Issues & Merge Requests'),
yAxisTitle: s__('InstanceStatistics|Items'),
xAxisTitle: s__('InstanceStatistics|Month'),
chartTitle: s__('UsageTrends|Issues & Merge Requests'),
yAxisTitle: s__('UsageTrends|Items'),
xAxisTitle: s__('UsageTrends|Month'),
queries: [
{
query,
title: __('Issues'),
identifier: 'ISSUES',
loadError: sprintf(s__('InstanceStatistics|There was an error fetching the issues')),
loadError: sprintf(s__('UsageTrends|There was an error fetching the issues')),
},
{
query,
title: __('Merge requests'),
identifier: 'MERGE_REQUESTS',
loadError: sprintf(
s__('InstanceStatistics|There was an error fetching the merge requests'),
),
loadError: sprintf(s__('UsageTrends|There was an error fetching the merge requests')),
},
],
},
Loading
Loading
Loading
Loading
@@ -113,14 +113,14 @@ export default {
},
},
i18n: {
yAxisTitle: s__('InstanceStatistics|Total projects & groups'),
yAxisTitle: s__('UsageTrends|Total projects & groups'),
xAxisTitle: __('Month'),
loadChartError: s__(
'InstanceStatistics|Could not load the projects and groups chart. Please refresh the page to try again.',
'UsageTrends|Could not load the projects and groups chart. Please refresh the page to try again.',
),
loadProjectsDataError: s__('InstanceStatistics|There was an error while loading the projects'),
loadGroupsDataError: s__('InstanceStatistics|There was an error while loading the groups'),
noDataMessage: s__('InstanceStatistics|No data available.'),
loadProjectsDataError: s__('UsageTrends|There was an error while loading the projects'),
loadGroupsDataError: s__('UsageTrends|There was an error while loading the groups'),
noDataMessage: s__('UsageTrends|No data available.'),
},
computed: {
isLoadingGroups() {
Loading
Loading
@@ -161,11 +161,11 @@ export default {
chartData() {
return [
{
name: s__('InstanceStatistics|Total projects'),
name: s__('UsageTrends|Total projects'),
data: this.projectChartData,
},
{
name: s__('InstanceStatistics|Total groups'),
name: s__('UsageTrends|Total groups'),
data: this.groupChartData,
},
];
Loading
Loading
Loading
Loading
@@ -4,12 +4,12 @@ import { deprecatedCreateFlash as createFlash } from '~/flash';
import { SUPPORTED_FORMATS, getFormatter } from '~/lib/utils/unit_format';
import { s__ } from '~/locale';
import * as Sentry from '~/sentry/wrapper';
import instanceStatisticsCountQuery from '../graphql/queries/instance_statistics_count.query.graphql';
import usageTrendsCountQuery from '../graphql/queries/usage_trends_count.query.graphql';
 
const defaultPrecision = 0;
 
export default {
name: 'InstanceCounts',
name: 'UsageCounts',
components: {
MetricCard,
},
Loading
Loading
@@ -20,7 +20,7 @@ export default {
},
apollo: {
counts: {
query: instanceStatisticsCountQuery,
query: usageTrendsCountQuery,
update(data) {
return Object.entries(data).map(([key, obj]) => {
const label = this.$options.i18n.labels[key];
Loading
Loading
@@ -42,14 +42,14 @@ export default {
},
i18n: {
labels: {
users: s__('InstanceStatistics|Users'),
projects: s__('InstanceStatistics|Projects'),
groups: s__('InstanceStatistics|Groups'),
issues: s__('InstanceStatistics|Issues'),
mergeRequests: s__('InstanceStatistics|Merge Requests'),
pipelines: s__('InstanceStatistics|Pipelines'),
users: s__('UsageTrends|Users'),
projects: s__('UsageTrends|Projects'),
groups: s__('UsageTrends|Groups'),
issues: s__('UsageTrends|Issues'),
mergeRequests: s__('UsageTrends|Merge Requests'),
pipelines: s__('UsageTrends|Pipelines'),
},
loadCountsError: s__('Could not load instance counts. Please refresh the page to try again.'),
loadCountsError: s__('Could not load usage counts. Please refresh the page to try again.'),
},
};
</script>
Loading
Loading
Loading
Loading
@@ -12,10 +12,10 @@ import ChartSkeletonLoader from '~/vue_shared/components/resizable_chart/skeleto
import { TODAY, START_DATE } from '../constants';
import { getAverageByMonth, getEarliestDate, generateDataKeys } from '../utils';
 
const QUERY_DATA_KEY = 'instanceStatisticsMeasurements';
const QUERY_DATA_KEY = 'usageTrendsMeasurements';
 
export default {
name: 'InstanceStatisticsCountChart',
name: 'UsageTrendsCountChart',
components: {
GlLineChart,
GlAlert,
Loading
Loading
fragment Count on InstanceStatisticsMeasurement {
fragment Count on UsageTrendsMeasurement {
count
recordedAt
}
Loading
Loading
@@ -2,7 +2,7 @@
#import "../fragments/count.fragment.graphql"
 
query getGroupsCount($first: Int, $after: String) {
groups: instanceStatisticsMeasurements(identifier: GROUPS, first: $first, after: $after) {
groups: usageTrendsMeasurements(identifier: GROUPS, first: $first, after: $after) {
nodes {
...Count
}
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
#import "../fragments/count.fragment.graphql"
 
query getProjectsCount($first: Int, $after: String) {
projects: instanceStatisticsMeasurements(identifier: PROJECTS, first: $first, after: $after) {
projects: usageTrendsMeasurements(identifier: PROJECTS, first: $first, after: $after) {
nodes {
...Count
}
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
#import "../fragments/count.fragment.graphql"
 
query getCount($identifier: MeasurementIdentifier!, $first: Int, $after: String) {
instanceStatisticsMeasurements(identifier: $identifier, first: $first, after: $after) {
usageTrendsMeasurements(identifier: $identifier, first: $first, after: $after) {
nodes {
...Count
}
Loading
Loading
#import "../fragments/count.fragment.graphql"
 
query getInstanceCounts {
projects: instanceStatisticsMeasurements(identifier: PROJECTS, first: 1) {
projects: usageTrendsMeasurements(identifier: PROJECTS, first: 1) {
nodes {
...Count
}
}
groups: instanceStatisticsMeasurements(identifier: GROUPS, first: 1) {
groups: usageTrendsMeasurements(identifier: GROUPS, first: 1) {
nodes {
...Count
}
}
users: instanceStatisticsMeasurements(identifier: USERS, first: 1) {
users: usageTrendsMeasurements(identifier: USERS, first: 1) {
nodes {
...Count
}
}
issues: instanceStatisticsMeasurements(identifier: ISSUES, first: 1) {
issues: usageTrendsMeasurements(identifier: ISSUES, first: 1) {
nodes {
...Count
}
}
mergeRequests: instanceStatisticsMeasurements(identifier: MERGE_REQUESTS, first: 1) {
mergeRequests: usageTrendsMeasurements(identifier: MERGE_REQUESTS, first: 1) {
nodes {
...Count
}
}
pipelines: instanceStatisticsMeasurements(identifier: PIPELINES, first: 1) {
pipelines: usageTrendsMeasurements(identifier: PIPELINES, first: 1) {
nodes {
...Count
}
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@
#import "../fragments/count.fragment.graphql"
 
query getUsersCount($first: Int, $after: String) {
users: instanceStatisticsMeasurements(identifier: USERS, first: $first, after: $after) {
users: usageTrendsMeasurements(identifier: USERS, first: $first, after: $after) {
nodes {
...Count
}
Loading
Loading
import Vue from 'vue';
import VueApollo from 'vue-apollo';
import createDefaultClient from '~/lib/graphql';
import InstanceStatisticsApp from './components/app.vue';
import UsageTrendsApp from './components/app.vue';
 
Vue.use(VueApollo);
 
Loading
Loading
@@ -10,7 +10,7 @@ const apolloProvider = new VueApollo({
});
 
export default () => {
const el = document.getElementById('js-instance-statistics-app');
const el = document.getElementById('js-usage-trends-app');
 
if (!el) return false;
 
Loading
Loading
@@ -18,7 +18,7 @@ export default () => {
el,
apolloProvider,
render(h) {
return h(InstanceStatisticsApp);
return h(UsageTrendsApp);
},
});
};
Loading
Loading
@@ -41,8 +41,8 @@ export function getAverageByMonth(items = [], options = {}) {
}
 
/**
* Takes an array of instance counts and returns the last item in the list
* @param {Array} arr array of instance counts in the form { count: Number, recordedAt: date String }
* Takes an array of usage counts and returns the last item in the list
* @param {Array} arr array of usage counts in the form { count: Number, recordedAt: date String }
* @return {String} the 'recordedAt' value of the earliest item
*/
export const getEarliestDate = (arr = []) => {
Loading
Loading
@@ -54,7 +54,7 @@ export const getEarliestDate = (arr = []) => {
* Takes an array of queries and produces an object with the query identifier as key
* and a supplied defaultValue as its value
* @param {Array} queries array of chart query configs,
* see ./analytics/instance_statistics/components/charts_config.js
* see ./analytics/usage_trends/components/charts_config.js
* @param {any} defaultValue value to set each identifier to
* @return {Object} key value pair of the form { queryIdentifier: defaultValue }
*/
Loading
Loading
import initInstanceStatisticsApp from '~/analytics/instance_statistics';
document.addEventListener('DOMContentLoaded', () => initInstanceStatisticsApp());
import initUsageTrendsApp from '~/analytics/usage_trends';
initUsageTrendsApp();
# frozen_string_literal: true
 
class Admin::InstanceStatisticsController < Admin::ApplicationController
class Admin::UsageTrendsController < Admin::ApplicationController
include Analytics::UniqueVisitsHelper
 
before_action :check_feature_flag
track_unique_visits :index, target_id: 'i_analytics_instance_statistics'
 
feature_category :devops_reports
 
def index
end
def check_feature_flag
render_404 unless Feature.enabled?(:instance_statistics, default_enabled: true)
end
end
Loading
Loading
@@ -3,13 +3,13 @@
module Resolvers
module Admin
module Analytics
module InstanceStatistics
module UsageTrends
class MeasurementsResolver < BaseResolver
include Gitlab::Graphql::Authorize::AuthorizeResource
 
type Types::Admin::Analytics::InstanceStatistics::MeasurementType, null: true
type Types::Admin::Analytics::UsageTrends::MeasurementType, null: true
 
argument :identifier, Types::Admin::Analytics::InstanceStatistics::MeasurementIdentifierEnum,
argument :identifier, Types::Admin::Analytics::UsageTrends::MeasurementIdentifierEnum,
required: true,
description: 'The type of measurement/statistics to retrieve.'
 
Loading
Loading
@@ -24,7 +24,7 @@ class MeasurementsResolver < BaseResolver
def resolve(identifier:, recorded_before: nil, recorded_after: nil)
authorize!
 
::Analytics::InstanceStatistics::Measurement
::Analytics::UsageTrends::Measurement
.recorded_after(recorded_after)
.recorded_before(recorded_before)
.with_identifier(identifier)
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@
module Types
module Admin
module Analytics
module InstanceStatistics
module UsageTrends
class MeasurementIdentifierEnum < BaseEnum
graphql_name 'MeasurementIdentifier'
description 'Possible identifier types for a measurement'
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment