Skip to content

Commit 7e636dd

Browse files
authored
make the labels unique
1 parent 53bd3a7 commit 7e636dd

File tree

2 files changed

+42
-32
lines changed

2 files changed

+42
-32
lines changed

TODO.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
- stats on when moved from one column to another ?
1010

1111
- Badges:
12-
- 🎭 Performer - most items in review (N items in review)
13-
- 🤝 Team player(Mate) - most items with multiple assignees
14-
- 🏋️ All in - most items in work
15-
- Riddle solver - most solved issues
1612
- 💯 Done - more issues solved then the sprint had on average per developer (> 1x rate)
1713
- 🚂 Steam powered - more issues solved then the sprint had on average per developer (> 1.5x rate)
1814
- 🚀 Unstoppable - more issues solved then the sprint had on average per developer (> 2x rate)
15+
16+
- 🎭 Performer - most items in review (N items in review)
17+
- 🤝 Team player(Mate) - most items with multiple assignees
18+
- 🏋️ All in - 75% of planned items most items in work
19+
- Riddle solver - most solved issues
1920
- 🧴 Sanitizer - most security bugs fixed
2021
- 🔭 Focused - one item assigned
2122
- 🧭 Explorer - most backlog items solved

src/views/renderIssuesBlock.ts

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -38,40 +38,39 @@ const sortIssuesListByUsername = (cardsWithIssue: ICardWithIssue[]) => {
3838
return result;
3939
};
4040

41-
const getIssuesForLabel = (
42-
label: string,
43-
labels: string[],
44-
cardsWithIssue: ICardWithIssue[],
45-
): ICardWithIssue[] => {
46-
const result = cardsWithIssue.filter(({ issue }) => {
41+
const findLabel = (labelName: string, found = true) => {
42+
return ({ issue }: ICardWithIssue) => {
4743
if (!issue) {
4844
return false;
4945
}
5046

51-
const firstLabelFromTheList = issue.labels.find((issueLabel) => {
52-
return labels.includes(issueLabel.name);
53-
});
54-
5547
const foundLabel = issue.labels.find((issueLabel) => {
56-
return issueLabel.name === label;
48+
return issueLabel.name === labelName;
5749
});
5850

59-
/**
60-
* The `labels` array has the descending priority for the defined labels,
61-
* hence if the found label is not the first in the list, dont use it
62-
*/
63-
if (firstLabelFromTheList !== foundLabel) {
64-
return false;
65-
}
51+
return !!foundLabel === found;
52+
}
53+
}
6654

67-
return !!foundLabel;
68-
});
55+
const getIssuesForLabel = (
56+
label: string,
57+
cardsWithIssue: ICardWithIssue[],
58+
): [ICardWithIssue[], ICardWithIssue[]] => {
59+
const originalCards = [...cardsWithIssue];
6960

70-
return result;
61+
const result = originalCards.filter(
62+
findLabel(label),
63+
);
64+
65+
const rest = originalCards.filter(
66+
findLabel(label, false),
67+
);
68+
69+
return [result, rest];
7170
};
7271

7372
const groupIssuesByLabels = (
74-
issues: ICardWithIssue[],
73+
cardsWithIssues: ICardWithIssue[],
7574
projectWithConfig: IProjectWithConfig,
7675
): TLabeledIssues => {
7776
const result: TLabeledIssues = {};
@@ -83,19 +82,29 @@ const groupIssuesByLabels = (
8382

8483
const includedIssues = new Set<ICardWithIssue>();
8584
for (let label of labels) {
86-
const issuesForLabel = sortIssuesListByUsername(
87-
getIssuesForLabel(label, labels, issues),
88-
);
85+
const [cardsForLabel, restCards] = getIssuesForLabel(label, cardsWithIssues);
86+
/**
87+
* !! We return the `restCards` above - the list of cards that does not hold
88+
* the label, and reassign the "rest" list to the original one, so we don't
89+
* match the same card against other labels. This enforces descending priority
90+
* of the `trackLabels` labels list defined in the project config.
91+
* e.g. with the ["port-forwarding", "workbench", "performance", "serverless"]
92+
* list in the config, the issues with both "port-forwarding" and "performance"
93+
* labels, will show up only in the` Port-forwarding` section since it has the
94+
* highe precedence over the "performance" label.
95+
*/
96+
cardsWithIssues = restCards;
8997

90-
result[label] = issuesForLabel;
98+
const sortedIssuesForLabel = sortIssuesListByUsername(cardsForLabel);
99+
result[label] = sortedIssuesForLabel;
91100

92-
for (let issueForLabel of issuesForLabel) {
101+
for (let issueForLabel of sortedIssuesForLabel) {
93102
includedIssues.add(issueForLabel);
94103
}
95104
}
96105

97106
// get all issues that have no label
98-
const notIncludedIssues = issues.filter((issue) => {
107+
const notIncludedIssues = cardsWithIssues.filter((issue) => {
99108
return !includedIssues.has(issue);
100109
});
101110

0 commit comments

Comments
 (0)