Merge branch 'al_new' into 'developing'
merge 'al_new' to 'developing' See merge request !8
Showing
1 changed file
with
7 additions
and
17 deletions
1 | var express = require('express'); | 1 | var express = require('express'); |
2 | var router = express.Router(); | 2 | var router = express.Router(); |
3 | var db = require('../lib/db'); | 3 | var db = require('../lib/db'); |
4 | -require('date-utils'); | ||
5 | - | ||
6 | -var newDate = new Date(); | ||
7 | 4 | ||
8 | /* GET home page. */ | 5 | /* GET home page. */ |
9 | router.get('/', function(req, res, next) { | 6 | router.get('/', function(req, res, next) { |
... | @@ -17,10 +14,10 @@ router.get('/', function(req, res, next) { | ... | @@ -17,10 +14,10 @@ router.get('/', function(req, res, next) { |
17 | var dataLen = 0; // 데이터 개수 | 14 | var dataLen = 0; // 데이터 개수 |
18 | var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음 | 15 | var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음 |
19 | var sql = ""; // 쿼리 | 16 | var sql = ""; // 쿼리 |
20 | - var index = 0; | 17 | + var count = 0; |
21 | 18 | ||
22 | // 이전 10분간 데이터 찾기 | 19 | // 이전 10분간 데이터 찾기 |
23 | - sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"; | 20 | + sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -20 MINUTE), '%Y-%m-%d %H:%i:%s')"; |
24 | db.query(sql, function(err, rows, fields){ | 21 | db.query(sql, function(err, rows, fields){ |
25 | if (err) { | 22 | if (err) { |
26 | console.log(err); | 23 | console.log(err); |
... | @@ -29,26 +26,18 @@ router.get('/', function(req, res, next) { | ... | @@ -29,26 +26,18 @@ router.get('/', function(req, res, next) { |
29 | empty = 1; | 26 | empty = 1; |
30 | } else { | 27 | } else { |
31 | for (var i = rows.length - 1; i >= 0; i--){ | 28 | for (var i = rows.length - 1; i >= 0; i--){ |
32 | - var temp = rows[i].time.getMinutesBetween(newDate); | ||
33 | - | ||
34 | - if(temp == index){ | ||
35 | probArr.unshift(rows[i].prob); | 29 | probArr.unshift(rows[i].prob); |
36 | time.unshift(rows[i].time); | 30 | time.unshift(rows[i].time); |
37 | ptArr.unshift(rows[i].temperature); | 31 | ptArr.unshift(rows[i].temperature); |
38 | wsArr.unshift(rows[i].wind); | 32 | wsArr.unshift(rows[i].wind); |
39 | rainArr.unshift(rows[i].rain); | 33 | rainArr.unshift(rows[i].rain); |
40 | - index = index + 1; | 34 | + count = count + 1; |
41 | - } | 35 | + |
42 | - else { | 36 | + if (count == 10){ |
43 | - empty = 1; | ||
44 | break; | 37 | break; |
45 | } | 38 | } |
46 | } | 39 | } |
47 | 40 | ||
48 | - if (empty == 1 && probArr.length != 0) | ||
49 | - empty = 0; | ||
50 | - } | ||
51 | - | ||
52 | dataLen = probArr.length; | 41 | dataLen = probArr.length; |
53 | res.render('index', { | 42 | res.render('index', { |
54 | empty, | 43 | empty, |
... | @@ -60,7 +49,8 @@ router.get('/', function(req, res, next) { | ... | @@ -60,7 +49,8 @@ router.get('/', function(req, res, next) { |
60 | dataLen | 49 | dataLen |
61 | }); | 50 | }); |
62 | } | 51 | } |
63 | - }) | 52 | + } |
53 | +}); | ||
64 | }); | 54 | }); |
65 | 55 | ||
66 | module.exports = router; | 56 | module.exports = router; | ... | ... |
-
Please register or login to post a comment