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
unknown
2018-12-06 11:51:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3b09d838f8c1f4895121d4e749b08d1ae894ff1f
3b09d838
1 parent
9f8139a3
db call modulize
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
lib/db.js
lib/socketio.js
lib/db.js
0 → 100644
View file @
3b09d83
const
mysql
=
require
(
'mysql'
);
const
DB_option
=
require
(
'./db_option'
);
module
.
exports
=
mysql
.
createConnection
(
DB_option
);
lib/socketio.js
View file @
3b09d83
...
...
@@ -19,12 +19,8 @@ module.exports = (server, app) => {
if
(
err
)
throw
err
;
// api의 대답이 있을경우 실행
if
(
api_res
)
{
const
sql
=
`INSERT INTO dataset (question,option_1,option_2,option_3,option_4,answer,user_id) VALUES (?,?,?,?,?,?,?)`
;
db
.
query
(
sql
,
[
question
,
option
[
0
],
option
[
1
],
option
[
2
],
option
[
3
],
machine_body
.
answer
,
user_id
],
function
(
err
,
result
)
{
if
(
err
)
throw
err
;
console
.
log
(
"dataset successfully inserted into DB"
)
});
return
response
.
send
(
{
answer
:
machine_body
.
answer
}
);
console
.
log
(
api_body
);
return
response
.
send
(
"ok"
);
}
});
},
60
*
1000
);
//1분마다 호출
...
...
Please
register
or
login
to post a comment