Add winners manually by posting /lottery/winners.

This commit is contained in:
2021-01-24 15:34:58 +01:00
parent 2f3a6aeba7
commit b5b61784cc
2 changed files with 72 additions and 2 deletions

View File

@@ -189,7 +189,21 @@ const deleteWines = () => {
return PreLotteryWine.deleteMany();
};
const allWinners = isAdmin => {
const addWinners = winners => {
return Promise.all(
winners.map(winner => {
let newWinnerElement = new VirtualWinner({
name: winner.name,
color: winner.color,
timestamp_drawn: new Date().getTime()
});
return newWinnerElement.save();
})
);
};
const allWinners = (isAdmin = false) => {
if (!isAdmin) {
return VirtualWinner.find().then(winners => winners.map(redactWinnerInfoMapper));
} else {
@@ -360,6 +374,7 @@ module.exports = {
updateWineById,
deleteWineById,
deleteWines,
addWinners,
allWinners,
winnerById,
deleteWinnerById,