Commit d16e1a49 authored by mfluharty's avatar mfluharty

Wire up the GraphQL query

i18n-ify strings
parent 444486ef
<script>
import { s__ } from '~/locale';
import MetricCard from '~/analytics/shared/components/metric_card.vue';
import getGroupTestCoverage from '../graphql/queries/get_group_test_coverage.query.graphql';
export default {
name: 'TestCoverageSummary',
components: {
MetricCard,
},
inject: {
groupFullPath: {
default: '',
},
},
apollo: {
group: {
query: getGroupTestCoverage,
variables() {
return {
groupFullPath: this.groupFullPath,
startDate: new Date(Date.now() - 604800000), // one week ago
};
},
result(res) {
const { projectCount, averageCoverage, coverageCount } =
res.data?.group?.codeCoverageActivities?.nodes?.[0] || {};
this.projectCount = projectCount;
this.averageCoverage = averageCoverage;
this.coverageCount = coverageCount;
},
error() {
this.hasError = true;
this.projectCount = null;
this.averageCoverage = null;
this.coverageCount = null;
},
watchLoading(isLoading) {
this.isLoading = isLoading;
},
},
},
data() {
return {
projectCount: null,
averageCoverage: null,
coverageCount: null,
hasError: false,
isLoading: false,
};
},
computed: {
metrics() {
return [
{
key: 'projectCount',
value: this.projectCount,
label: s__('RepositoriesAnalytics|Projects with Tests'),
},
{
key: 'averageCoverage',
value: this.averageCoverage,
unit: '%',
label: s__('RepositoriesAnalytics|Average Coverage by Job'),
},
{
key: 'coverageCount',
value: this.coverageCount,
label: s__('RepositoriesAnalytics|Total Number of Coverages'),
},
];
},
},
};
</script>
<template>
<metric-card
:title="__('Overall Activity')"
:metrics="[
{ key: 1, value: 45, unit: '', label: 'Projects with Tests' },
{ key: 2, value: 72, unit: '%', label: 'Average Coverage by Job' },
{ key: 3, value: 103, unit: '', label: 'Total Number of Coverages' },
]"
:is-loading="false"
/>
<metric-card :title="__('Overall Activity')" :metrics="metrics" :is-loading="isLoading" />
</template>
query getGroupTestCoverage($groupFullPath: ID!, $startDate: Date!, $last: Int = 1) {
group(fullPath: $groupFullPath) {
codeCoverageActivities(startDate: $startDate, last: $last) {
nodes {
projectCount
averageCoverage
coverageCount
date
}
}
}
}
......@@ -19082,6 +19082,9 @@ msgstr ""
msgid "Outdent"
msgstr ""
msgid "Overall Activity"
msgstr ""
msgid "Overridden"
msgstr ""
......@@ -22730,6 +22733,9 @@ msgstr ""
msgid "Repositories Analytics"
msgstr ""
msgid "RepositoriesAnalytics|Average Coverage by Job"
msgstr ""
msgid "RepositoriesAnalytics|Coverage"
msgstr ""
......@@ -22760,12 +22766,18 @@ msgstr ""
msgid "RepositoriesAnalytics|Please select projects to display."
msgstr ""
msgid "RepositoriesAnalytics|Projects with Tests"
msgstr ""
msgid "RepositoriesAnalytics|Test Code Coverage"
msgstr ""
msgid "RepositoriesAnalytics|There was an error fetching the projects."
msgstr ""
msgid "RepositoriesAnalytics|Total Number of Coverages"
msgstr ""
msgid "Repository"
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment