2023-10-15 20:37:03 +02:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { DateTime } from 'luxon';
|
2015-11-12 15:52:14 +01:00
|
|
|
|
2020-01-18 10:13:50 +01:00
|
|
|
export default class PollEvaluationParticipantsTable extends Component {
|
2023-10-15 17:32:11 +02:00
|
|
|
get optionsPerDay() {
|
|
|
|
const { poll } = this.args;
|
2020-01-18 10:13:50 +01:00
|
|
|
|
2023-10-15 17:32:11 +02:00
|
|
|
const optionsPerDay = new Map();
|
|
|
|
for (const option of poll.options.toArray()) {
|
|
|
|
optionsPerDay.set(
|
|
|
|
option.day,
|
|
|
|
optionsPerDay.has(option.day) ? optionsPerDay.get(option.day) + 1 : 0
|
|
|
|
);
|
|
|
|
}
|
2020-01-18 10:13:50 +01:00
|
|
|
|
2023-10-15 17:32:11 +02:00
|
|
|
return new Map(
|
|
|
|
Array.from(optionsPerDay.entries()).map(([dayString, count]) => [
|
|
|
|
DateTime.fromISO(dayString).toJSDate(),
|
|
|
|
count,
|
|
|
|
])
|
|
|
|
);
|
|
|
|
}
|
2020-01-18 10:13:50 +01:00
|
|
|
|
2023-10-15 17:32:11 +02:00
|
|
|
get usersSorted() {
|
|
|
|
const { poll } = this.args;
|
|
|
|
return poll.users
|
|
|
|
.toArray()
|
|
|
|
.sort((a, b) => (a.creationDate > b.creationDate ? 1 : -1));
|
|
|
|
}
|
2020-01-18 10:13:50 +01:00
|
|
|
}
|