Commit d16e1a49 authored by mfluharty's avatar mfluharty

Wire up the GraphQL query

i18n-ify strings
parent 444486ef
<script> <script>
import { s__ } from '~/locale';
import MetricCard from '~/analytics/shared/components/metric_card.vue'; import MetricCard from '~/analytics/shared/components/metric_card.vue';
import getGroupTestCoverage from '../graphql/queries/get_group_test_coverage.query.graphql';
export default { export default {
name: 'TestCoverageSummary', name: 'TestCoverageSummary',
components: { components: {
MetricCard, 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> </script>
<template> <template>
<metric-card <metric-card :title="__('Overall Activity')" :metrics="metrics" :is-loading="isLoading" />
: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"
/>
</template> </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 "" ...@@ -19082,6 +19082,9 @@ msgstr ""
msgid "Outdent" msgid "Outdent"
msgstr "" msgstr ""
msgid "Overall Activity"
msgstr ""
msgid "Overridden" msgid "Overridden"
msgstr "" msgstr ""
...@@ -22730,6 +22733,9 @@ msgstr "" ...@@ -22730,6 +22733,9 @@ msgstr ""
msgid "Repositories Analytics" msgid "Repositories Analytics"
msgstr "" msgstr ""
msgid "RepositoriesAnalytics|Average Coverage by Job"
msgstr ""
msgid "RepositoriesAnalytics|Coverage" msgid "RepositoriesAnalytics|Coverage"
msgstr "" msgstr ""
...@@ -22760,12 +22766,18 @@ msgstr "" ...@@ -22760,12 +22766,18 @@ msgstr ""
msgid "RepositoriesAnalytics|Please select projects to display." msgid "RepositoriesAnalytics|Please select projects to display."
msgstr "" msgstr ""
msgid "RepositoriesAnalytics|Projects with Tests"
msgstr ""
msgid "RepositoriesAnalytics|Test Code Coverage" msgid "RepositoriesAnalytics|Test Code Coverage"
msgstr "" msgstr ""
msgid "RepositoriesAnalytics|There was an error fetching the projects." msgid "RepositoriesAnalytics|There was an error fetching the projects."
msgstr "" msgstr ""
msgid "RepositoriesAnalytics|Total Number of Coverages"
msgstr ""
msgid "Repository" msgid "Repository"
msgstr "" 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