/api/groups and /api/invites refactored, fixed some inserts/updates in which I didn't include the id
This commit is contained in:
@@ -58,6 +58,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
{ id: fields.id },
|
||||
{
|
||||
$set: {
|
||||
id: fields.id,
|
||||
solutions,
|
||||
score: {
|
||||
correct: speakingReverseMarking[backendRequest.data.overall || 0] || 0,
|
||||
|
||||
@@ -54,6 +54,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
await db.collection("stats").updateOne(
|
||||
{ id: fields.id },
|
||||
{
|
||||
id: fields.id,
|
||||
solutions,
|
||||
score: {
|
||||
correct: speakingReverseMarking[backendRequest.data.overall || 0] || 0,
|
||||
|
||||
@@ -39,7 +39,8 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const solutions = correspondingStat.solutions.map((x) => ({...x, evaluation: backendRequest.data}));
|
||||
await db.collection("stats").updateOne(
|
||||
{ id: (req.body as Body).id},
|
||||
{
|
||||
{
|
||||
id: (req.body as Body).id,
|
||||
solutions,
|
||||
score: {
|
||||
correct: writingReverseMarking[backendRequest.data.overall],
|
||||
@@ -58,7 +59,7 @@ async function getCorrespondingStat(id: string, index: number): Promise<Stat> {
|
||||
const correspondingStat = await db.collection("stats").findOne<Stat>({ id: id});
|
||||
|
||||
if (correspondingStat) return correspondingStat;
|
||||
|
||||
|
||||
await delay(3 * 10000);
|
||||
return getCorrespondingStat(id, index + 1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user