mirror of
https://akkoma.dev/AkkomaGang/akkoma-fe
synced 2025-04-30 11:09:30 +08:00
polls: base fractions on voters for multiple choice polls
This allows discerning how many voters agreed with an option and aligns with other clients. However, a backend bug makes this impossible for remote multiple choice polls, so retain current behaviour for anything affected.
This commit is contained in:
parent
2914eaf1ca
commit
473ba89355
1 changed files with 10 additions and 2 deletions
|
@ -50,6 +50,13 @@ export default {
|
||||||
totalVotesCount () {
|
totalVotesCount () {
|
||||||
return this.poll.votes_count
|
return this.poll.votes_count
|
||||||
},
|
},
|
||||||
|
totalFractionBase () {
|
||||||
|
// Due to a backend bug, we might not have any voter count info for remote polls
|
||||||
|
// in this case, fall back to count of votes even for multiple cjoice polls
|
||||||
|
// to be able to at least display _something_
|
||||||
|
const total_base = this.poll.multiple ? this.poll.voters_count : this.poll.votes_count
|
||||||
|
return total_base > 0 ? total_base : this.poll.votes_count
|
||||||
|
},
|
||||||
containerClass () {
|
containerClass () {
|
||||||
return {
|
return {
|
||||||
loading: this.loading
|
loading: this.loading
|
||||||
|
@ -70,10 +77,11 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
percentageForOption (count) {
|
percentageForOption (count) {
|
||||||
return this.totalVotesCount === 0 ? 0 : Math.round(count / this.totalVotesCount * 100)
|
const total = this.totalFractionBase
|
||||||
|
return total === 0 ? 0 : Math.round(count / total * 100)
|
||||||
},
|
},
|
||||||
resultTitle (option) {
|
resultTitle (option) {
|
||||||
return `${option.votes_count}/${this.totalVotesCount} ${this.$t('polls.votes')}`
|
return `${option.votes_count}/${this.totalFractionBase} ${this.$t('polls.votes')}`
|
||||||
},
|
},
|
||||||
fetchPoll () {
|
fetchPoll () {
|
||||||
this.$store.dispatch('refreshPoll', { id: this.statusId, pollId: this.poll.id })
|
this.$store.dispatch('refreshPoll', { id: this.statusId, pollId: this.poll.id })
|
||||||
|
|
Loading…
Reference in a new issue