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-11 16:35:23 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
567b844558136ca6c8fa909f303bdd63f62b631b
567b8445
1 parent
6c9b906a
렌더링 파트 알고리즘 수정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
22 deletions
routes/index.js
routes/index.js
View file @
567b844
var
express
=
require
(
'express'
);
var
router
=
express
.
Router
();
var
db
=
require
(
'../lib/db'
);
require
(
'date-utils'
);
var
newDate
=
new
Date
();
/* GET home page. */
router
.
get
(
'/'
,
function
(
req
,
res
,
next
)
{
...
...
@@ -17,10 +14,10 @@ router.get('/', function(req, res, next) {
var
dataLen
=
0
;
// 데이터 개수
var
empty
=
0
;
// 초기값 유뮤, 0 : 자료 있음, 1 : 자료 없음
var
sql
=
""
;
// 쿼리
var
index
=
0
;
var
count
=
0
;
// 이전 10분간 데이터 찾기
sql
=
"SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -
1
0 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
sql
=
"SELECT * FROM weatherInfo WHERE time >= DATE_FORMAT(DATE_ADD(now(), INTERVAL -
2
0 MINUTE), '%Y-%m-%d %H:%i:%s')"
;
db
.
query
(
sql
,
function
(
err
,
rows
,
fields
){
if
(
err
)
{
console
.
log
(
err
);
...
...
@@ -29,26 +26,18 @@ router.get('/', function(req, res, next) {
empty
=
1
;
}
else
{
for
(
var
i
=
rows
.
length
-
1
;
i
>=
0
;
i
--
){
var
temp
=
rows
[
i
].
time
.
getMinutesBetween
(
newDate
);
if
(
temp
==
index
){
probArr
.
unshift
(
rows
[
i
].
prob
);
time
.
unshift
(
rows
[
i
].
time
);
ptArr
.
unshift
(
rows
[
i
].
temperature
);
wsArr
.
unshift
(
rows
[
i
].
wind
);
rainArr
.
unshift
(
rows
[
i
].
rain
);
index
=
index
+
1
;
}
else
{
empty
=
1
;
probArr
.
unshift
(
rows
[
i
].
prob
);
time
.
unshift
(
rows
[
i
].
time
);
ptArr
.
unshift
(
rows
[
i
].
temperature
);
wsArr
.
unshift
(
rows
[
i
].
wind
);
rainArr
.
unshift
(
rows
[
i
].
rain
);
count
=
count
+
1
;
if
(
count
==
10
){
break
;
}
}
if
(
empty
==
1
&&
probArr
.
length
!=
0
)
empty
=
0
;
}
dataLen
=
probArr
.
length
;
res
.
render
(
'index'
,
{
empty
,
...
...
@@ -60,7 +49,8 @@ router.get('/', function(req, res, next) {
dataLen
});
}
})
}
});
});
module
.
exports
=
router
;
...
...
Please
register
or
login
to post a comment