Skip to content

Commit f92df79

Browse files
committed
Fix sorting of next card due time
The times were sorted alphabetically, not numerically...
1 parent 119977d commit f92df79

File tree

2 files changed

+32
-29
lines changed

2 files changed

+32
-29
lines changed

src/TimestampFormatter.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const isNumeric = function (n) {
1717
return !isNaN(parseFloat(n)) && isFinite(n);
1818
};
1919

20-
const convertDurationToTimestamp = function (duration) {
20+
export const convertDurationToTimestamp = function (duration) {
2121
let parts = duration.substring(0, duration.length - 1).split('.');
2222
if (parts.length === 1) {
2323
return parseInt(parts[0]) * 1000000000;
@@ -58,4 +58,4 @@ const TimestampFormatter = {
5858
});
5959
}
6060
};
61-
export default TimestampFormatter;
61+
export default TimestampFormatter;

src/components/team/TeamYellowCardNextDue.vue

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,42 @@
66
</template>
77

88
<script>
9-
import {TEAM_BLUE, TEAM_YELLOW} from "../../refereeState";
9+
import {TEAM_BLUE, TEAM_YELLOW} from "@/refereeState";
10+
import {convertDurationToTimestamp} from "@/TimestampFormatter";
1011
11-
export default {
12-
name: "TeamYellowCardNextDue",
13-
props: {
14-
teamColor: String,
15-
},
16-
data() {
17-
return {
18-
TEAM_YELLOW: TEAM_YELLOW,
19-
TEAM_BLUE: TEAM_BLUE
20-
}
12+
export default {
13+
name: "TeamYellowCardNextDue",
14+
props: {
15+
teamColor: String,
16+
},
17+
data() {
18+
return {
19+
TEAM_YELLOW: TEAM_YELLOW,
20+
TEAM_BLUE: TEAM_BLUE
21+
}
22+
},
23+
computed: {
24+
team() {
25+
return this.$store.state.matchState.teamState[this.teamColor]
2126
},
22-
computed: {
23-
team() {
24-
return this.$store.state.matchState.teamState[this.teamColor]
25-
},
26-
latestCardTime() {
27-
if (this.activeYellowCards.length > 0) {
28-
let cards = [];
29-
for (let card of this.activeYellowCards) {
30-
cards.push(card.timeRemaining)
31-
}
32-
cards.sort()
33-
return cards[0];
27+
latestCardTime() {
28+
if (this.activeYellowCards.length > 0) {
29+
let cards = [];
30+
for (let card of this.activeYellowCards) {
31+
cards.push(convertDurationToTimestamp(card.timeRemaining))
3432
}
35-
return 0;
36-
},
37-
activeYellowCards() {
38-
return this.team.yellowCards.filter(e => e.timeRemaining !== '0s');
33+
cards.sort(function (a, b) {
34+
return a - b;
35+
});
36+
return cards[0];
3937
}
38+
return 0;
39+
},
40+
activeYellowCards() {
41+
return this.team.yellowCards.filter(e => e.timeRemaining !== '0s');
4042
}
4143
}
44+
}
4245
</script>
4346

4447
<style scoped>

0 commit comments

Comments
 (0)