배희수

Merge branch 'al_new' into 'developing'

merge 'al_new' to 'developing'



See merge request !8
var express = require('express');
var router = express.Router();
var db = require('../lib/db');
require('date-utils');
var newDate = new Date();
/* GET home page. */
router.get('/', function(req, res, next) {
......@@ -17,10 +14,10 @@ router.get('/', function(req, res, next) {
var dataLen = 0; // 데이터 개수
var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var sql = ""; // 쿼리
var index = 0;
var count = 0;
// 이전 10분간 데이터 찾기
sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')";
sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -20 MINUTE), '%Y-%m-%d %H:%i:%s')";
db.query(sql, function(err, rows, fields){
if (err) {
console.log(err);
......@@ -29,26 +26,18 @@ router.get('/', function(req, res, next) {
empty = 1;
} else {
for (var i = rows.length - 1; i >= 0; i--){
var temp = rows[i].time.getMinutesBetween(newDate);
if(temp == index){
probArr.unshift(rows[i].prob);
time.unshift(rows[i].time);
ptArr.unshift(rows[i].temperature);
wsArr.unshift(rows[i].wind);
rainArr.unshift(rows[i].rain);
index = index + 1;
}
else {
empty = 1;
count = count + 1;
if (count == 10){
break;
}
}
if (empty == 1 && probArr.length != 0)
empty = 0;
}
dataLen = probArr.length;
res.render('index', {
empty,
......@@ -60,7 +49,8 @@ router.get('/', function(req, res, next) {
dataLen
});
}
})
}
});
});
module.exports = router;
......