From c0362c96f2210e1d21966b75e94a70879c64ef87 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tobias=20=C3=98rstad?= <tobiasio@ntnu.no>
Date: Thu, 5 Mar 2020 14:56:55 +0100
Subject: [PATCH] Hotfix. Last change got weird. Issue #6

---
 backend/api/highscores.js | 47 ---------------------------------------
 1 file changed, 47 deletions(-)

diff --git a/backend/api/highscores.js b/backend/api/highscores.js
index eead9ba..c037a10 100644
--- a/backend/api/highscores.js
+++ b/backend/api/highscores.js
@@ -37,19 +37,11 @@ router.get("/gamescore/:userid/:gameid", (req, res) => {
   );
 });
 
-<<<<<<< HEAD
 router.post("/highscore", (req, res) => {
   MongoClient.connect(
     connectionUrl,
     { useNewUrlParser: true, useUnifiedTopology: true },
     (err, client) => {
-=======
-router.post("/highscore/:userid/:gameid/:score", (req, res) => {
-  MongoClient.connect(
-    connectionUrl,
-    { useNewUrlParser: true, useUnifiedTopology: true },
-    async (err, client) => {
->>>>>>> 4e2462fe51615bf8aa1aed7144654cf98a918327
       // Unable to connect to database
       if (err) {
         res.sendStatus(500); // Internal server error
@@ -59,7 +51,6 @@ router.post("/highscore/:userid/:gameid/:score", (req, res) => {
       const db = client.db("gameWare");
       const collection = "highscores";
 
-<<<<<<< HEAD
       db.collection(collection).updateOne(
         {
           gameid: req.body.gameid,
@@ -75,44 +66,6 @@ router.post("/highscore/:userid/:gameid/:score", (req, res) => {
           res.json(result);
         }
       );
-=======
-      const queryresult = await db.collection(collection).findOne({
-        gameid: req.params.gameid,
-        userid: req.params.userid
-      });
-
-      if (queryresult) {
-        db.collection(collection).updateOne(
-          {
-            gameid: req.params.gameid,
-            userid: req.params.userid
-          },
-          { $set: { value: parseInt(req.params.score) } },
-          (err, result) => {
-            if (err) {
-              res.sendStatus(500); // Internal server error
-              return;
-            }
-            res.json(result);
-          }
-        );
-      } else {
-        db.collection(collection).insertOne(
-          {
-            gameid: req.params.gameid,
-            userid: req.params.userid,
-            value: parseInt(req.params.score)
-          },
-          (err, result) => {
-            if (err) {
-              res.sendStatus(500); // Internal server error
-              return;
-            }
-            res.json(result);
-          }
-        );
-      }
->>>>>>> 4e2462fe51615bf8aa1aed7144654cf98a918327
     }
   );
 });
-- 
GitLab