Skip to content

Commit

Permalink
Merge pull request #61 from Tekken-Supporter/feature/sw0501
Browse files Browse the repository at this point in the history
Modify: 승률 업데이트 기능 수정
  • Loading branch information
sw0501 authored Nov 29, 2023
2 parents 5895fa0 + 48b8c42 commit b4c9e8e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions routes/challenge.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,24 +331,24 @@ router.post('/result',async(req,res)=>{
if (err) reject(err);
else resolve(results);
});

});
const wins = result[0].wins;
const losses = result[0].losses;
const win_losses = result[0].win_losses;
const loss_losses = result[0].loss_losses;

const wins = result[0].wins;
const losses = result[0].losses;
const win_losses = result[0].win_losses;
const loss_losses = result[0].loss_losses;

// Winrate 계산
const denominator = wins + losses + win_losses + loss_losses;
const winrate = denominator !== 0 ? (wins + losses) / denominator : 0;
// Winrate 계산
const denominator = wins + losses + win_losses + loss_losses;
const winrate = denominator !== 0 ? (wins + losses) / denominator : 0;

// userinfo 테이블의 Winrate 값을 업데이트하는 쿼리
const updateQuery = 'UPDATE userinfo SET Winrate = ? WHERE name = ?';
// userinfo 테이블의 Winrate 값을 업데이트하는 쿼리
const updateQuery = 'UPDATE userinfo SET Winrate = ? WHERE name = ?';

new Promise((resolve, reject) => {
connection.query(updateQuery, [winrate, username], (err, results, field) => {
if (err) reject(err);
else resolve();
});
new Promise((resolve, reject) => {
connection.query(updateQuery, [winrate, username], (err, results, field) => {
if (err) reject(err);
else resolve();
});
});
}
Expand Down

0 comments on commit b4c9e8e

Please sign in to comment.