Showing
1 changed file
with
10 additions
and
9 deletions
... | @@ -17,7 +17,7 @@ router.get('/', function(req, res, next) { | ... | @@ -17,7 +17,7 @@ router.get('/', function(req, res, next) { |
17 | var dataLen = 0; // 데이터 개수 | 17 | var dataLen = 0; // 데이터 개수 |
18 | var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음 | 18 | var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음 |
19 | var sql = ""; // 쿼리 | 19 | var sql = ""; // 쿼리 |
20 | - var index; | 20 | + var index = 0; |
21 | 21 | ||
22 | // 이전 10분간 데이터 찾기 | 22 | // 이전 10분간 데이터 찾기 |
23 | sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"; | 23 | sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"; |
... | @@ -28,16 +28,16 @@ router.get('/', function(req, res, next) { | ... | @@ -28,16 +28,16 @@ router.get('/', function(req, res, next) { |
28 | if (rows.length == 0) { | 28 | if (rows.length == 0) { |
29 | empty = 1; | 29 | empty = 1; |
30 | } else { | 30 | } else { |
31 | - dataLen = rows.length; | 31 | + for (var i = rows.length - 1; i >= 0; i--){ |
32 | - for (index = 0; index < rows.length; index++){ | 32 | + var temp = rows[i].time.getMinutesBetween(newDate); |
33 | - var temp = rows[index].time.getMinutesBetween(newDate); | ||
34 | 33 | ||
35 | if(temp == index){ | 34 | if(temp == index){ |
36 | - probArr.push(rows[index].prob); | 35 | + probArr.unshift(rows[i].prob); |
37 | - time.push(rows[index].time); | 36 | + time.unshift(rows[i].time); |
38 | - ptArr.push(rows[index].temperature); | 37 | + ptArr.unshift(rows[i].temperature); |
39 | - wsArr.push(rows[index].wind); | 38 | + wsArr.unshift(rows[i].wind); |
40 | - rainArr.push(rows[index].rain); | 39 | + rainArr.unshift(rows[i].rain); |
40 | + index = index + 1; | ||
41 | } | 41 | } |
42 | else { | 42 | else { |
43 | empty = 1; | 43 | empty = 1; |
... | @@ -49,6 +49,7 @@ router.get('/', function(req, res, next) { | ... | @@ -49,6 +49,7 @@ router.get('/', function(req, res, next) { |
49 | empty = 0; | 49 | empty = 0; |
50 | } | 50 | } |
51 | 51 | ||
52 | + dataLen = probArr.length; | ||
52 | res.render('index', { | 53 | res.render('index', { |
53 | empty, | 54 | empty, |
54 | time, | 55 | time, | ... | ... |
-
Please register or login to post a comment