<commit_before>//create the routes to be used by the sensors for logging data

var db = require("../models");

// Routes
module.exports = function(app) {
    
    //landing page for app

    //TODO - change this route to be specific to a single sensor.
    app.get("/api/data/", function(req, res) {
        db.Data.findAll({}).then(function(results) {
            res.json(results);
        });
    });
    
    //to allow sensor to do a get request for configuration data
    app.get("/api/config/:id", function(req, res){
        db.Sensor.findAll({
            where: {
                id: req.params.id
            }
        }).then(function(results) {
            res.json(results);
        });
    });

    //add a new sensor
    app.post("/api/new", function(req, res){
        db.Sensor.create(req.body).then(function(results){
            res.json(results);
        });
    });

    //sensor to post a new record
    app.post("/api/record", function(req, res) {
        db.Data.create(req.body).then(function(results) {
            res.json(results);
        });
    });

    //TODO - add 5 routes to update the different status values for the sensor.

    app.put("/api/pumpOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });

      app.put("/api/lightOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });
      
      app.put("/api/autoLightOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });

      app.put("/api/autoPumpOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });

      app.put("/api/targetSoil", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });
    
    //a single route for checking online status - for use on view
    
    app.get("/api/config", function(req, res){
        db.Sensor.findAll({})
        .then(function(results) {
            res.json(results);
        });
    });

};

<commit_msg>changed search route for data to be for single sensor<commit_after>//create the routes to be used by the sensors for logging data

var db = require("../models");

// Routes
module.exports = function(app) {
    
    //landing page for app

    //TODO - change this route to be specific to a single sensor.
    app.get("/api/data/:id", function(req, res) {
        db.Data.findAll({
          where: {
            id: req.params.id
        }
        }).then(function(results) {
            res.json(results);
        });
    });
    
    //to allow sensor to do a get request for configuration data
    app.get("/api/config/:id", function(req, res){
        db.Sensor.findAll({
            where: {
                id: req.params.id
            }
        }).then(function(results) {
            res.json(results);
        });
    });

    //add a new sensor
    app.post("/api/new", function(req, res){
        db.Sensor.create(req.body).then(function(results){
            res.json(results);
        });
    });

    //sensor to post a new record
    app.post("/api/record", function(req, res) {
        db.Data.create(req.body).then(function(results) {
            res.json(results);
        });
    });

    //TODO - add 5 routes to update the different status values for the sensor.

    app.put("/api/pumpOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });

      app.put("/api/lightOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });
      
      app.put("/api/autoLightOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });

      app.put("/api/autoPumpOn", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });

      app.put("/api/targetSoil", function(req, res) {
        db.Sensor.update(req.body,
          {
            where: {
              id: req.body.id
            }
          })
        .then(function() {
          res.json();
        });
      });
    
    //a single route for checking online status - for use on view
    
    app.get("/api/config", function(req, res){
        db.Sensor.findAll({})
        .then(function(results) {
            res.json(results);
        });
    });

};


{'fraction_non_alphanumeric': 0.15134837644468904, 'fraction_numerical': 0.000366905155017428, 'mean_word_length': 1.2984822934232716, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1508443', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1617, 'n_words': 319}