Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.DS_Store
db-config.json
key.json
node_modules/
sftp-config.json
npm-debug.log
.DS_Store
*.json
*.log
43 changes: 43 additions & 0 deletions controller/authorizationCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const mysql = require('mysql');
var async = require('async');
var dbconfig = require(__dirname+'/../config/db-config.json');
var connection = mysql.createConnection(dbconfig);

exports.adminAccess = ( req, res, next ) => {
const sess = req.session;

if(sess.name)
res.redirect('/dashboard');
else
res.render('login.html',{error:null});
}

exports.adminLogin = ( req, res, next ) => {
const sess = req.session;

connection.query('select admin_name from ADMINACCOUNT where admin_id=\''+req.body.adminId+'\' and admin_pw=\''+req.body.password+'\'',(err,rows)=>{
if(rows.length>0){
sess.name = rows[0].admin_name;
res.redirect('/dashboard');
}
else{
res.render('login.html',{error: "Input wrong id or password"});
}
});
}

exports.adminLogout = ( req, res, next ) => {
const sess = req.session;

if(sess.name){
req.session.destroy((err)=>{
if(err){
console.log(err);
}else{
res.redirect('/');
}
})
}else{
res.redirect('/');
}
}
588 changes: 588 additions & 0 deletions controller/dashboardCtrl.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion controller/notiCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const fcm = require(__dirname+'/../common/fcm.js');
const pushLogModel = require(__dirname+'/../model/pushLogModel.js');
var util = require(__dirname+'/../common/util.js');

var util = require(__dirname+'/../common/util.js');
var moment = require('moment');


Expand Down
111 changes: 111 additions & 0 deletions controller/recoAnalysisCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
const mysql = require('mysql');
var async = require('async');
var dbconfig = require(__dirname+'/../config/db-config.json');
var connection = mysql.createConnection(dbconfig);

exports.renderRecoAnalysis = ( req, res, next ) => {
const sess = req.session;
if(!sess.name){
res.redirect('/');
return;
}

var mainRegionDict=[];
var detailRegionDict={};
var noneRecommendList=[];

// Need to paging
async.parallel([
function(callback){
function DisplayDT(a){
if(a<10)
a = '0'+a;

return a;
};
connection.query(
`select
U.user_gender,
U.user_birth,
E.summary,
E.start_dt,
E.end_dt,
E.location
from EVENT as E
inner join CALENDAR as C
on E.calendar_hashkey = C.calendar_hashkey
inner join USERACCOUNT as UA
on C.account_hashkey = UA.account_hashkey
inner join USER as U
on UA.user_hashkey = U.user_hashkey
where
E.reco_state = 2`,(err,rows)=>{
if(err) throw err;

noneRecommendList=rows;
var length = rows.length;
//console.log(new Date(rows[i].start_dt).format(""))
for(var i=0; i<length; i++){
var age='알수 없음';
var gap=new Date().getFullYear() - parseInt(noneRecommendList[i].user_birth);
if(gap > 0 && gap < 100)
age=gap;

var sDate = new Date(rows[i].start_dt);
noneRecommendList[i].converted_start_dt = sDate.getFullYear().toString().substring(2,4)+DisplayDT(sDate.getMonth()+1)+DisplayDT(sDate.getDate())+' '+DisplayDT(sDate.getHours())+':'+DisplayDT(sDate.getMinutes());//+':'+DisplayDT(sDate.getSeconds());
//console.log(sDate.getFullYear()+'/'+(sDate.getMonth()+1)+'/'+sDate.getDate()+' '+sDate.getHours()+':'+sDate.getMinutes()+':'+sDate.getSeconds());
//console.log(noneRecommendList.converted_start_dt);
var eDate = new Date(rows[i].end_dt);
var eDateTime = (eDate.getFullYear().toString().substring(2,4)+DisplayDT(eDate.getMonth()+1)+DisplayDT(eDate.getDate())) == (sDate.getFullYear().toString().substring(2,4)+DisplayDT(sDate.getMonth()+1)+DisplayDT(sDate.getDate())) ? '': eDate.getFullYear().toString().substring(2,4)+DisplayDT(eDate.getMonth()+1)+DisplayDT(eDate.getDate());
noneRecommendList[i].converted_end_dt = eDateTime+' '+DisplayDT(eDate.getHours())+':'+DisplayDT(eDate.getMinutes());//+':'+DisplayDT(eDate.getSeconds());
noneRecommendList[i].age = age;
}
callback(err, noneRecommendList);
});
},
function(callback){
connection.query(
`select
R.main_region,
R.region,
(select sum(RECO.reco_cnt) from RECOMMENDATION as RECO where RECO.main_region = R.main_region) as main_region_recommends,
(select sum(RECO.reco_cnt) from RECOMMENDATION as RECO where RECO.region = R.region) as detail_region_recommends
from RECOMMENDATION as R
where
R.main_region != 'NULL'
or R.main_region != 'None'
group by R.main_region, R.region, main_region_recommends`,(err, rows)=>{
if(err) throw err;
//var totalMainRegionCounts=0;
//for(var i=0; i<rows.length; i++)
// totalMainRegionCounts += rows[i].main_region_recommends;
var mainRegionTempDict ={};
for(var i=0; i<rows.length; i++){
if(mainRegionTempDict[rows[i].main_region] == null)
mainRegionTempDict[rows[i].main_region] = rows[i].main_region_recommends;

detailRegionDict[i]={
'main_region' : rows[i].main_region,
'region' : rows[i].region,
'detail_count': rows[i].detail_region_recommends,
'detail_percent': Math.floor(rows[i].detail_region_recommends/rows[i].main_region_recommends*100)
};
}
for(var i=0; i<Object.keys(mainRegionTempDict).length ; i++){
mainRegionDict.push({
'label' : Object.keys(mainRegionTempDict)[i],
'value': Object.values(mainRegionTempDict)[i]
});
}
callback(err, rows);
});

}], function(err, ressult){
res.render('simple.html',{
admin_name : sess.name,
mainRegionDict : mainRegionDict,
detailRegionDict : detailRegionDict,
noneRecommendList : noneRecommendList
});
}); // end async.parallel
}
16 changes: 16 additions & 0 deletions controller/userAnalysisCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const mysql = require('mysql');
var async = require('async');
var dbconfig = require(__dirname+'/../config/db-config.json');
var connection = mysql.createConnection(dbconfig);

exports.renderUserAnalysis = ( req, res, next ) => {
const sess = req.session;
if(!sess.name){
res.redirect('/');
return;
}

res.render('chartjs.html',{
admin_name : sess.name
});
}
15 changes: 0 additions & 15 deletions dash-forever-err.log

This file was deleted.

Empty file removed dash-forever-out.log
Empty file.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"moment": "^2.18.1",
"mongoose": "^4.9.6",
"moongoose": "0.0.5",
"mysql": "^2.11.1"
"mysql": "^2.11.1",
"request": "^2.81.0"
}
}
Loading