Toggle navigation
Toggle navigation
This project
Loading...
Sign in
MotherProject
/
Probability Death
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
DESKTOP-PC6TBNS\강환석씨
2018-12-09 18:50:13 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
75bb7f585c7d29b13206a7d2e8c7b3420f489a41
75bb7f58
2 parents
8d026b13
9ac94a70
Merge branch 'developing' of
http://khuhub.khu.ac.kr/2017104029/2018_2_project
into socket_db
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
23 deletions
routes/index.js
routes/index.js
View file @
75bb7f5
...
...
@@ -4,38 +4,45 @@ var db = require('../lib/db');
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
// 자외선지수, 불쾌지수, 열지수, 체감 온도, 바람속도, 현재기온, 하늘 상태, 강우량, 태풍, 낙뢰, 특보, 현재 시간
var
uvr
,
discomfort
,
heat
,
sensibleTem
,
windSpeed
,
presentTem
,
skyState
,
rainfall
,
typhoon
,
lightning
,
alert
,
time
;
// 쿼리문
var
sql
=
'SELECT * FROM kkonzi_test.weatherInfo WHERE kkonzi_test.time > DATE_FORMAT(DATE_ADD(now(), INTERVAL -1 MINUTE), "%Y-%m-%d %H:%i:%s")'';
// 렌더링 변수
var
time
=
new
Array
();
// 타임스탬프
var
ptArr
=
new
Array
();
// 현재 온도
var
wsArr
=
new
Array
();
// 풍속
var
rainArr
=
new
Array
();
// 강우량
var
probArr
=
new
Array
();
// 사망 확률
var
empty
=
0
;
// 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var
sql
=
""
;
// 쿼리
var
index
;
// 이전 10분간 데이터 찾기
sql
=
"SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
if (rows.length == 0){
if
(
rows
.
length
!=
10
)
{
empty
=
1
;
}
else
{
probArr
.
push
(
rows
[
0
].
prob
);
time
.
push
(
rows
[
0
].
time
);
ptArr
.
push
(
rows
[
0
].
temperature
);
wsArr
.
push
(
rows
[
0
].
wind
);
rainArr
.
push
(
rows
[
0
].
rain
);
}
else {
}
var tmp = rows.length - 1;
time = rows[temp].time;
uvr = rows[temp].UV;
discomfort = rows[temp].discomfort;
heat = rows[temp].heat;
sensibleTem = rows[temp].SensibleT;
windSpeed = rows[temp].wspd;
presentTem = rows[temp].CurrentT;
skyState = rows[temp].sky;
rainfall = rows[temp].rain;
typhoon = rows[temp].typhoon;
lightning = rows[temp].lightning;
alert = rows[temp].alert;
res
.
render
(
'index'
,
{
empty
,
time
,
ptArr
,
wsArr
,
rainArr
,
probArr
});
}
})
res.render('
index
', {title: '
Express
'
});
});
module
.
exports
=
router
;
...
...
Please
register
or
login
to post a comment