조민지

loop revised

...@@ -148,7 +148,8 @@ ...@@ -148,7 +148,8 @@
148 "requestUrl": "/weather/index/th?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240", 148 "requestUrl": "/weather/index/th?appKey=c13b1a68-ef31-4131-a1b7-4069c263f82d&version=1&lat=37.239795&lon=127.083240",
149 "message": "성공" 149 "message": "성공"
150 } 150 }
151 -}{ 151 +}
152 +{
152 "weather": { 153 "weather": {
153 "wIndex": { 154 "wIndex": {
154 "heatIndex": [ 155 "heatIndex": [
......
...@@ -98,8 +98,5 @@ module.exports = (server, app) => { ...@@ -98,8 +98,5 @@ module.exports = (server, app) => {
98 clearInterval(API_CALL); //연결 종료시 해제 98 clearInterval(API_CALL); //연결 종료시 해제
99 }) 99 })
100 }) 100 })
101 -
102 -
103 -
104 } 101 }
105 102
......
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) {
...@@ -14,52 +11,38 @@ router.get('/', function(req, res, next) { ...@@ -14,52 +11,38 @@ router.get('/', function(req, res, next) {
14 var wsArr = new Array(); // 풍속 11 var wsArr = new Array(); // 풍속
15 var rainArr = new Array(); // 강우량 12 var rainArr = new Array(); // 강우량
16 var probArr = new Array(); // 사망 확률 13 var probArr = new Array(); // 사망 확률
17 - var dataLen = 0; // 데이터 개수
18 var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음 14 var empty = 0; // 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
19 var sql = ""; // 쿼리 15 var sql = ""; // 쿼리
20 var index; 16 var index;
21 17
22 // 이전 10분간 데이터 찾기 18 // 이전 10분간 데이터 찾기
23 - sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')";
24 - db.query(sql, function(err, rows, fields){
25 - if (err) {
26 - console.log(err);
27 - } else {
28 - if (rows.length == 0) {
29 - empty = 1;
30 - } else {
31 - dataLen = rows.length;
32 - for (index = 0; index < rows.length; index++){
33 - var temp = rows[index].time.getMinutesBetween(newDate);
34 19
35 - if(temp == index){ 20 + sql = "SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')";
36 - probArr.push(rows[index].prob); 21 +
37 - time.push(rows[index].time); 22 + db.query(sql, function(err, rows, fields){
38 - ptArr.push(rows[index].temperature); 23 + if (err) {
39 - wsArr.push(rows[index].wind); 24 + console.log(err);
40 - rainArr.push(rows[index].rain); 25 + } else {
41 - } 26 + if (rows.length != 10) {
42 - else {
43 empty = 1; 27 empty = 1;
44 - break; 28 + } else {
29 + probArr.push(rows[0].prob);
30 + time.push(rows[0].time);
31 + ptArr.push(rows[0].temperature);
32 + wsArr.push(rows[0].wind);
33 + rainArr.push(rows[0].rain);
45 } 34 }
35 +
36 + res.render('index', {
37 + empty,
38 + time,
39 + ptArr,
40 + wsArr,
41 + rainArr,
42 + probArr
43 + });
46 } 44 }
47 - 45 + })
48 - if (empty == 1 && probArr.length != 0)
49 - empty = 0;
50 - }
51 -
52 - res.render('index', {
53 - empty,
54 - time,
55 - ptArr,
56 - wsArr,
57 - rainArr,
58 - probArr,
59 - dataLen
60 - });
61 - }
62 - })
63 }); 46 });
64 47
65 module.exports = router; 48 module.exports = router;
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
38 ></div> 38 ></div>
39 </div> 39 </div>
40 </div> 40 </div>
41 +<<<<<<< HEAD
41 42
42 <script src="/socket.io/socket.io.js"></script> 43 <script src="/socket.io/socket.io.js"></script>
43 <script> 44 <script>
...@@ -48,6 +49,9 @@ ...@@ -48,6 +49,9 @@
48 }); 49 });
49 </script> 50 </script>
50 51
52 +=======
53 +
54 +>>>>>>> 0f5edf6316e2444f5fd2a050fed5e771e5141733
51 <!-- 첫번째 그래프 --> 55 <!-- 첫번째 그래프 -->
52 <script type="text/javascript"> 56 <script type="text/javascript">
53 Highcharts.chart("container1", { 57 Highcharts.chart("container1", {
......