All files / ee/app/assets/javascripts/burndown_chart/components open_timebox_summary.vue

60% Statements 9/15
0% Branches 0/8
54.55% Functions 6/11
60% Lines 9/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100  7x 7x 7x                                                                   2x           2x       1x                                   1x                               1x                   1x                
<script>
import { __ } from '~/locale';
import { Namespace, Unit } from '../constants';
import summaryStatsQuery from '../graphql/iteration_issues_summary.query.graphql';
 
export default {
  apollo: {
    issues: {
      query: summaryStatsQuery,
      variables() {
        return this.queryVariables;
      },
      update(data) {
        return {
          open: data[this.namespaceType]?.openIssues?.[this.displayValue] || 0,
          assigned: data[this.namespaceType]?.assignedIssues?.[this.displayValue] || 0,
          closed: data[this.namespaceType]?.closedIssues?.[this.displayValue] || 0,
        };
      },
      error() {
        this.error = __('Error loading issues');
      },
    },
  },
  props: {
    fullPath: {
      type: String,
      required: true,
    },
    iterationId: {
      type: String,
      required: true,
    },
    namespaceType: {
      type: String,
      required: false,
      default: Namespace.Group,
      validator: (value) => Object.values(Namespace).includes(value),
    },
    displayValue: {
      type: String,
      required: false,
      default: Unit.count,
      validator: (val) => Unit[val],
    },
  },
  data() {
    return {
      issues: {
        assigned: 0,
        open: 0,
        closed: 0,
      },
    };
  },
  computed: {
    queryVariables() {
      return {
        fullPath: this.fullPath,
        id: this.iterationId,
        isGroup: this.namespaceType === Namespace.Group,
        weight: this.displayValue === Unit.weight,
      };
    },
    columns() {
      return [
        {
          title: __('Completed'),
          value: this.issues.closed,
        },
        {
          title: __('Incomplete'),
          value: this.issues.assigned,
        },
        {
          title: __('Unstarted'),
          value: this.issues.open,
        },
      ];
    },
    total() {
      return this.issues.open + this.issues.assigned + this.issues.closed;
    },
  },
  methods: {
    percent(val) {
      if (!this.total) return 0;
      return ((val / this.total) * 100).toFixed(0);
    },
  },
  render() {
    return this.$scopedSlots.default({
      columns: this.columns,
      loading: this.$apollo.queries.issues.loading,
      total: this.total,
    });
  },
};
</script>