Refactored team to ballot.
This commit is contained in:
1 parent
b52f76d3bc
commit
ae7e65ba44
3 files changed
+30
-30
No files matched your search
+4
-4
@@ -1,7 +1,7 @@
|
||||
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
|
||||
import {createBundle} from "./bundler.ts";
|
||||
import {Context} from "https://deno.land/x/oak@v12.2.0/context.ts";
|
||||
import {Team} from "./shared.ts";
|
||||
import {Ballot} from "./shared.ts";
|
||||
|
||||
const router = new Router();
|
||||
|
||||
@@ -40,7 +40,7 @@ function getUserIndex(userId: string, ballotId: string, questionId: string){
|
||||
questionId]
|
||||
}
|
||||
|
||||
async function persistTeams(userId: any, ballots: Team[]): Promise<void> {
|
||||
async function persistBallots(userId: any, ballots: Ballot[]): Promise<void> {
|
||||
const kv = await Deno.openKv();
|
||||
for(const ballot of ballots){
|
||||
for(const question of Object.keys(ballot.scores)){
|
||||
@@ -58,8 +58,8 @@ router.post("/api/v1/vote/:userid", async (ctx: Context)=> {
|
||||
ctx.throw(415);
|
||||
}
|
||||
const body = await ctx.request.body().value;
|
||||
const teams = body as Team[];
|
||||
await persistTeams(userId, teams);
|
||||
const ballots = body as Ballot[];
|
||||
await persistBallots(userId, ballots);
|
||||
console.log(body);
|
||||
ctx.response.body = userId;
|
||||
|
||||
|
||||
Reference in new issue
Block a user