diff --git a/src/controllers/carController.js b/src/controllers/carController.js index a60e519..701d745 100644 --- a/src/controllers/carController.js +++ b/src/controllers/carController.js @@ -41,18 +41,15 @@ exports.updateCarLocation = async function updateCarLocation(carID, location) { exports.updateCarStatus = async function updateCarStatus(carID, status, location) { try { - const update = {carStatus: status}; + const update = {carStatus: status, destination: location}; const options = {new: true}; const result = await Car.findByIdAndUpdate(carID, {$set: update}, options); - await updateCarDestination(carID, location); - if(status !==0){ - setTimeout(async () => { - const update = {carStatus: 0}; - await Car.findByIdAndUpdate(carID, {$set: update}, options); - await requestController.deleteLastRequest(carID); - await updateCarLocation(carID, location); - }, 5 * 1000 * 60); - } + setTimeout(async () => { + const update = {carStatus: 0}; + await Car.findByIdAndUpdate(carID, {$set: update}, options); + await requestController.deleteLastRequest(carID); + await this.updateCarLocation(carID, location); + }, 5 * 1000 ); return result; } catch(error) { diff --git a/src/controllers/requestController.js b/src/controllers/requestController.js index 2eb30ed..9c19862 100644 --- a/src/controllers/requestController.js +++ b/src/controllers/requestController.js @@ -5,7 +5,6 @@ const userController = require("./userController"); const functionController = require("./functionController"); function stopBracelet(braceletID) { - console.log("hello") const b =JSON.parse(`{"braceletId": "${braceletID}"}`); fetch('http://localhost:1337/api/stop/', {