2023-04-11 18:06:01 +02:00
|
|
|
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
2023-04-18 07:40:11 +02:00
|
|
|
import {databasePromise} from "../../libs/cloud/mongodb";
|
2023-04-11 18:06:01 +02:00
|
|
|
|
2023-04-21 06:59:37 +02:00
|
|
|
export const handler = async (req, res) => {
|
2023-04-11 18:06:01 +02:00
|
|
|
let db = await databasePromise;
|
|
|
|
let objectDate = new Date();
|
|
|
|
|
|
|
|
let month = objectDate.getMonth();
|
|
|
|
let year = objectDate.getFullYear();
|
|
|
|
if (month < 10) {
|
|
|
|
month = `0${month}`;
|
|
|
|
}
|
|
|
|
|
2023-07-27 15:55:06 +02:00
|
|
|
const { uid, gameVersion, track, value, feedback, index } = req.body;
|
2023-04-11 18:06:01 +02:00
|
|
|
if (feedback === "optimal" && value >= 0.00 && value <= 1.00) {
|
2023-07-27 15:55:06 +02:00
|
|
|
await db.collection('reports_game_' + gameVersion).updateOne(
|
2023-04-11 18:06:01 +02:00
|
|
|
{ track },
|
2023-04-11 18:17:11 +02:00
|
|
|
{
|
|
|
|
$inc: { [`feedback_cnt_${index}`]: 1 },
|
|
|
|
$push: { [`params_${index}`]: value },
|
|
|
|
},
|
2023-04-11 18:06:01 +02:00
|
|
|
{ upsert: true },
|
|
|
|
);
|
2023-07-28 05:01:40 +02:00
|
|
|
await db.collection('reports_val_' + gameVersion).updateOne(
|
|
|
|
{ track },
|
|
|
|
{
|
|
|
|
$inc: { [`feedback_cnt_${index}`]: 1 },
|
|
|
|
},
|
|
|
|
{ upsert: true },
|
|
|
|
);
|
2023-04-11 18:06:01 +02:00
|
|
|
}
|
|
|
|
res.status(200).json({status: "ok"});
|
2023-04-21 06:59:37 +02:00
|
|
|
};
|
|
|
|
export default handler;
|