in backend/Functions/Main/score_put/app.js [30:58]
async function updateScoreboard(gameId, quizName, playerName, score) {
const Key = { gameId, playerName };
let scoreData;
try {
scoreData = await ddb.get({
TableName: scoresTableName,
Key,
}).promise();
} catch (e) {
console.error(`could not get score info ${JSON.stringify(e.stack)}`);
return { statusCode: 500, body: 'Error getting score' };
}
if (!(Object.prototype.hasOwnProperty.call(scoreData, 'Item'))) {
// store the record only if player has not taken the quiz
const Item = {
gameId, quizName, playerName, score,
};
try {
await ddb.put({
TableName: scoresTableName,
Item,
}).promise();
} catch (e) {
console.error(`could not save score info ${JSON.stringify(e.stack)}`);
return { statusCode: 500, body: e.stack };
}
}
return { statusCode: 200, body: 'score saved' };
}