Skip to content

Commit

Permalink
Support pm25 and pm25Index at same time, we should fix the issue in n…
Browse files Browse the repository at this point in the history
…ear future
  • Loading branch information
evanxd committed Apr 24, 2016
1 parent 517811c commit 508104a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/sensors.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ Sensors.prototype = {
addSensor: function(req, res, next) {
// if (config.closedBeta) {
// return res.jsonp({ result: 'fail',
// message: 'Currently we are doing closed beta. You cannot sing up.' });
// message:
// 'Currently we are doing closed beta. You cannot sing up.' });
// }
var creatorId = req.params.userId;
var projectName = req.params.projectName;
Expand Down Expand Up @@ -113,18 +114,19 @@ Sensors.prototype = {
var data = req.body;
var sensorId = req.params.sensorId;
var datetime = new Date();
var pm25Index = data.pm25Index;
// FIXME: Let's remove the `data.pm25Index` variable.
var pm25 = data.pm25 || data.pm25Index;
var sensorData = new Pm25Data({
datetime: datetime,
sensorId: sensorId,
pm25Index: pm25Index
pm25Index: data.pm25
});

Sensor.find({ _id: sensorId }, function (err, sensors) {
if (err) return console.error(err);
var sensor = sensors[0];
sensor.set('latestUpdate', datetime);
sensor.set('pm25Index', pm25Index);
sensor.set('pm25Index', pm25);
sensor.save(function() {
err && console.error(err);
});
Expand Down

0 comments on commit 508104a

Please sign in to comment.