voting with counts

This commit is contained in:
Sendou 2020-02-10 18:56:00 +02:00
parent 8792d3f693
commit c4e8dc828b
4 changed files with 16 additions and 20 deletions

View File

@ -22,8 +22,12 @@ const summaryMap = summary => {
<b>
<span style={{ ...getColor(score.total) }}>{score.total}</span>%
</b>{" "}
(EU <span style={getColor(score.eu)}>{score.eu}</span>% | NA{" "}
<span style={getColor(score.na)}>{score.na}</span>%)
{score.eu_count.length > 0 && (
<>
(EU <span>{score.eu_count.join("/")}</span> | NA{" "}
<span>{score.na_count.join("/")}</span>)
</>
)}
{summary.vouched && (
<Popup
content="User was vouched to the server last month"

View File

@ -11,8 +11,8 @@ export const summaries = gql`
}
score {
total
eu
na
eu_count
na_count
}
plus_server
suggested

View File

@ -96,8 +96,6 @@ const typeDef = gql`
type Score {
total: Float!
eu: Float
na: Float
eu_count: [Int]
na_count: [Int]
}
@ -637,16 +635,6 @@ const resolvers = {
const same_total = same_region.reduce((acc, cur) => acc + cur)
const other_total = other_region.reduce((acc, cur) => acc + cur)
const same_score = +(
((same_total / same_region.length + 2) / 4) *
100
).toFixed(2)
const other_score = +(
((other_total / other_region.length + 1) / 2) *
100
).toFixed(2)
const total_score = +(
((same_total / same_region.length +
other_total / other_region.length +
@ -660,10 +648,12 @@ const resolvers = {
const scoreIndex = scoreMap[cur]
if (!acc[scoreIndex]) acc[scoreIndex] = 1
else acc[scoreIndex] = acc[scoreIndex] + 1
return acc
}
const same_count = same_region.reduce(countReducer, [])
const other_count = other_region.reduce(countReducer, [])
const same_count = same_region.reduce(countReducer, [0, 0, 0, 0])
const other_count = other_region.reduce(countReducer, [0, 0, 0, 0])
const summary = {
discord_id,

View File

@ -9,8 +9,10 @@ const summarySchema = new mongoose.Schema({
suggested: Boolean,
score: {
total: { type: Number, required: true, min: 0, max: 100 },
eu: { type: Number, required: true, min: 0, max: 100 },
na: { type: Number, required: true, min: 0, max: 100 },
eu: { type: Number, min: 0, max: 100 },
na: { type: Number, min: 0, max: 100 },
eu_count: [Number],
na_count: [Number],
},
})