diff --git a/src/app.js b/src/app.js index 4bce29e..d44f170 100644 --- a/src/app.js +++ b/src/app.js @@ -6,7 +6,7 @@ const cron = require('node-cron'); dotenv.config(); const app = express(); -const port = 8080; +const port = process.env.PORT cron.schedule("40 * * * * *", () => { console.log("Running Job"); diff --git a/src/temperature/temperature.controller.js b/src/temperature/temperature.controller.js index 1cb8caf..0a50bfa 100644 --- a/src/temperature/temperature.controller.js +++ b/src/temperature/temperature.controller.js @@ -5,7 +5,8 @@ temperature = express.Router(); temperature.get('/hour-Avg/:day/:month/:year/:hours', ( req, res ) => { - var query = `SELECT avg(celsius) FROM log where log.day = '${req.params.day}' and log.month = '${req.params.month}' + var query = `SELECT avg(celsius) FROM log where log.day = '${req.params.day}' + and log.month = '${req.params.month}' and log.year = '${req.params.year}' and log.hours = '${req.params.hours}'; );` database.get(query, (err,row) =>{ @@ -20,8 +21,9 @@ temperature.get('/hour-Avg/:day/:month/:year/:hours', ( req, res ) => { }); temperature.get('/day-Avg/:day/:month/:year', ( req, res ) => { - var query = `SELECT avg(celsius) FROM log where log.day = '${req.params.day}' and log.month = '${req.params.month}' - and log.year = '${req.params.year}'; );` + var query = `SELECT avg(celsius) FROM log where log.day = '${req.params.day}' + and log.month = '${req.params.month}' + and log.year = '${req.params.year}'; );` database.get(query, (err,row) =>{ if(err) {