Add code to make the stuff work
This commit is contained in:
parent
a18b73fe52
commit
3d9feabe88
15 changed files with 517 additions and 0 deletions
26
src/endpoints/management/get_winners.ts
Normal file
26
src/endpoints/management/get_winners.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import { config, db } from "@/main"
|
||||
|
||||
export default {
|
||||
method: `GET`, path: `/bracket/winners`,
|
||||
async handler() {
|
||||
let winners: string[] = [];
|
||||
let highest = -1;
|
||||
|
||||
// Find the winners of the quote
|
||||
for (var i in db.bracket.quotes) {
|
||||
if (db.bracket.votes[i] > highest) {
|
||||
winners = [ db.bracket.quotes[i] ];
|
||||
highest = db.bracket.votes[i];
|
||||
} else if (db.bracket.votes[i] === highest) {
|
||||
winners.push(db.bracket.quotes[i]);
|
||||
};
|
||||
};
|
||||
|
||||
// Ensure that the all elimination limit didn't get hit
|
||||
if (winners.length > Math.floor(config.discord.quote_max / 2)) {
|
||||
return { winners: [] };
|
||||
};
|
||||
|
||||
return { winners };
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue