배희수

Merge branch 'algorithm' into 'developing'

merge 'algorithm' to 'developing'



See merge request !2
1 var express = require('express'); 1 var express = require('express');
2 var router = express.Router(); 2 var router = express.Router();
3 -var mysql = require('mysql'); 3 +var db = require('../lib/db')
4 4
5 /* GET home page. */ 5 /* GET home page. */
6 router.get('/', function(req, res, next) { 6 router.get('/', function(req, res, next) {
7 -
8 - // connection.query('SELECT * FROM ');
9 -
10 // 자외선지수, 불쾌지수, 열지수, 체감 온도, 바람속도, 현재기온, 하늘 상태, 강우량, 태풍, 낙뢰 7 // 자외선지수, 불쾌지수, 열지수, 체감 온도, 바람속도, 현재기온, 하늘 상태, 강우량, 태풍, 낙뢰
11 var uvr, discomfort, heat, sensibleTem, windSpeed, presentTem, skyState, rainfall, typhoon, lightning; 8 var uvr, discomfort, heat, sensibleTem, windSpeed, presentTem, skyState, rainfall, typhoon, lightning;
12 // 사망 확률 9 // 사망 확률
13 var deathProb; 10 var deathProb;
14 11
12 + // 쿼리문
13 + var sql = 'SELECT * FROM kkonzi_test.weatherInfo';
14 + db.query(sql, function(err, rows, fields){
15 + if (err) {
16 + console.log(err);
17 + } else {
18 + var tmp = rows.length - 1;
19 + uvr = rows[temp].uvr;
20 + discomfort = rows[temp].discomfort;
21 + heat = rows[temp].heat;
22 + sensibleTem = rows[temp].sensibleTem;
23 + windSpeed = rows[temp].windSpeed;
24 + presentTem = rows[temp].presentTem;
25 + skyState = rows[temp].skyState;
26 + rainfall = rows[temp].rainfall;
27 + typhoon = rows[temp].typhoon;
28 + lightning = rows[temp].lightning;
29 + }
30 + })
31 +
15 deathProb = uvr + discomfort + heat + sensibleTem + windSpeed + presentTem + skyState + rainfall + typhoon + lightning; 32 deathProb = uvr + discomfort + heat + sensibleTem + windSpeed + presentTem + skyState + rainfall + typhoon + lightning;
33 +
34 + sql = 'INSERT INTO kkonzi_test.deathProb (prob) VALUES (?)';
35 + var params = deathProb;
36 +
37 + db.query(sql, function(err, rows, fields){
38 + if (err) {
39 + console.log(err);
40 + } else {
41 + console.log('Success!');
42 + }
43 + }
44 + })
45 +
16 res.render('index', {title: 'Express'}); 46 res.render('index', {title: 'Express'});
17 }); 47 });
18 48
......