Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김주희
/
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
배희수
2018-12-09 18:49:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3c4939a1f2eac111bf35252192a49bd59a27dfa5
3c4939a1
1 parent
66a5e1af
렌더링 알고리즘 구현
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
28 deletions
routes/index.js
routes/index.js
View file @
3c4939a
...
...
@@ -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")'';
db.query(sql, function(err, rows, fields){
if (err) {
console.log(err);
} else {
if (rows.length == 0){
// 렌더링 변수
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
;
}
else {
// 이전 10분간 데이터 찾기
}
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;
}
})
sql
=
"SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -10 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
res.render('
index
', {title: '
Express
'
});
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
}
else
{
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
);
}
res
.
render
(
'index'
,
{
empty
,
time
,
ptArr
,
wsArr
,
rainArr
,
probArr
});
}
})
});
module
.
exports
=
router
;
...
...
Please
register
or
login
to post a comment