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
111 changes: 56 additions & 55 deletions server/controllers/controllerTown.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion server/controllers/geo.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function GeoController(lat, lon, lang, country) {
console.error(err);
}
else {
console.info('geoctrl cached domain:', domain, ', result:', result);
console.debug('geoctrl cached domain:', domain, ', result:', result);
}
});

Expand Down
2 changes: 1 addition & 1 deletion server/controllers/kma/kma.forecast.zone.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class KmaForecastZoneController {
}

_request(url) {
log.info({kmaForecastZoneCodeUrl: url});
log.debug({kmaForecastZoneCodeUrl: url});
return new Promise((resolve, reject) => {
let options = {json:true, timeout: 3000};
async.retry(3,
Expand Down
17 changes: 8 additions & 9 deletions server/controllers/kma/kma.town.current.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ kmaTownCurrentController.prototype.saveCurrent = function(newData, callback){

modelKmaTownCurrent.update({mCoord: coord, fcsDate: fcsDate}, newItem, {upsert:true}, function(err){
if(err){
log.error('KMA Town C> Fail to update current item');
log.error(err);
log.info(JSON.stringify(newItem));
log.error('KMA Town C> Fail to update current item', err);
// log.info(JSON.stringify(newItem));
return cb();
}

Expand Down Expand Up @@ -100,12 +99,12 @@ kmaTownCurrentController.prototype.getCurrentFromDB = function(modelCurrent, coo
var ret = [];
var pubDate = kmaTimelib.getKoreaTimeString(result[result.length-1].pubDate);

log.info('KMA Town C> get Data : ', result.length);
log.debug('KMA Town C> get Data : ', result.length);
result.forEach(function(item){
var newItem = {};
var curData = item.currentData;

//log.info(JSON.stringify(item));
//log.debug(JSON.stringify(item));
commonString.forEach(function(string){
newItem[string] = curData[string];
});
Expand Down Expand Up @@ -133,7 +132,7 @@ kmaTownCurrentController.prototype.checkPubDate = function(model, srcList, dateS
var pubDate = kmaTimelib.getKoreaDateObj(''+ dateString.date + dateString.time);
var errCode = 0;

log.info('KMA Town C> checkPubDate pubDate : ', pubDate.toString());
log.debug('KMA Town C> checkPubDate pubDate : ', pubDate.toString());
try{
async.mapSeries(srcList,
function(src,cb){
Expand All @@ -145,7 +144,7 @@ kmaTownCurrentController.prototype.checkPubDate = function(model, srcList, dateS

for(var i=0 ; i<dbList.length ; i++){
if(dbList[i].pubDate.getTime() === pubDate.getTime()){
log.info('KMA Town C> Already updated : ', src, dateString);
log.debug('KMA Town C> Already updated : ', src, dateString);
return cb(null);
}
}
Expand All @@ -161,8 +160,8 @@ kmaTownCurrentController.prototype.checkPubDate = function(model, srcList, dateS
return true;
});

log.info('KMA Town C> Count of the list for the updating : ', result.length);
log.info(JSON.stringify(result));
log.debug('KMA Town C> Count of the list for the updating : ', result.length);
log.debug(JSON.stringify(result));

return callback(errCode, result);
}
Expand Down
16 changes: 8 additions & 8 deletions server/controllers/kma/kma.town.mid.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ kmaTownMidController.prototype.saveMid = function(type, newData, overwrite, call
db.update({regId: regId}, newItem, {upsert:true}, function(err){
if(err){
log.error('KMA Town M> Fail to update Mid : '+ type + ' ID : ' + regId);
log.info(JSON.stringify(newItem));
// log.info(JSON.stringify(newItem));
return cb();
}
cb();
Expand All @@ -67,7 +67,7 @@ kmaTownMidController.prototype.saveMid = function(type, newData, overwrite, call
db.update({regId: regId, pubDate: pubDate}, newItem, {upsert:true}, function(err){
if(err){
log.error('KMA Town M> Fail to update Mid'+ type + 'item');
log.info(JSON.stringify(newItem));
// log.info(JSON.stringify(newItem));
return cb();
}

Expand All @@ -79,10 +79,10 @@ kmaTownMidController.prototype.saveMid = function(type, newData, overwrite, call
var limitedTime = kmaTimelib.getPast8DaysTime(pubDate);
log.debug('KMA Town M> finished to save town.mid : ', type);
if(overwrite){
log.info('KMA Town M> remove all item before pubData: ', pubDate.toString());
log.debug('KMA Town M> remove all item before pubData: ', pubDate.toString());
db.remove({regId: regId, "fcsDate": {$lt:pubDate}}).exec();
}else{
log.info('KMA Town M> remove all past 8days items: ', limitedTime.toString());
log.debug('KMA Town M> remove all past 8days items: ', limitedTime.toString());
db.remove({regId: regId, "fcsDate": {$lte:limitedTime}}).exec();
}

Expand Down Expand Up @@ -190,7 +190,7 @@ kmaTownMidController.prototype.checkPubDate = function(type, srcList, dateString
var pubDate = kmaTimelib.getKoreaDateObj(''+ dateString.date + dateString.time);
var errCode = 0;

log.info('KMA Town M> pubDate : ', pubDate.toString(), 'Type : ', type);
log.debug('KMA Town M> pubDate : ', pubDate.toString(), 'Type : ', type);
try{
var db = dbType[type];
if(db == undefined){
Expand All @@ -212,12 +212,12 @@ kmaTownMidController.prototype.checkPubDate = function(type, srcList, dateString

for(var i=0 ; i<dbList.length ; i++){
if(dbList[i].pubDate.getTime() === pubDate.getTime()){
log.info('KMA Town M> Already updated : ', src, dateString, src.code);
log.debug('KMA Town M> Already updated : ', src, dateString, src.code);
return cb(null);
}
}

log.info('KMA Town M> Need to update : ', src.code);
log.debug('KMA Town M> Need to update : ', src.code);
cb(null, src);
});
},
Expand All @@ -229,7 +229,7 @@ kmaTownMidController.prototype.checkPubDate = function(type, srcList, dateString
return true;
});

log.info('KMA Town M> Count of the list for the updating : ', result.length);
log.debug('KMA Town M> Count of the list for the updating : ', result.length);
log.silly('KMA Town M> ', JSON.stringify(result));

return callback(errCode, result);
Expand Down
14 changes: 7 additions & 7 deletions server/controllers/kma/kma.town.short.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ kmaTownShortController.prototype.saveShort = function(newData, callback){
modelKmaTownShort.update({mCoord: coord, fcsDate: fcsDate}, newItem, {upsert:true}, function(err){
if(err){
log.error('KMA Town S> Fail to update short item');
log.info(JSON.stringify(newItem));
// log.info(JSON.stringify(newItem));
return cb();
}

Expand Down Expand Up @@ -80,7 +80,7 @@ kmaTownShortController.prototype.getShortFromDB = function(modelCurrent, coord,
var ret = [];
var pubDate = kmaTimelib.getKoreaTimeString(result[result.length-1].pubDate);

log.info('KMA Town S> get Data : ', result.length);
log.debug('KMA Town S> get Data : ', result.length);
result.forEach(function(item){
var newItem = {};
var shortData = item.shortData;
Expand All @@ -95,7 +95,7 @@ kmaTownShortController.prototype.getShortFromDB = function(modelCurrent, coord,
ret.push(newItem);
});

log.info('KMA Town S> pubDate : ', pubDate);
log.debug('KMA Town S> pubDate : ', pubDate);
callback(errorNo, {pubDate: pubDate, ret:ret});
});

Expand All @@ -114,7 +114,7 @@ kmaTownShortController.prototype.checkPubDate = function(model, srcList, dateStr
var pubDate = kmaTimelib.getKoreaDateObj(''+ dateString.date + dateString.time);
var errCode = 0;

log.info('KMA Town S> pubDate : ', pubDate.toString());
log.debug('KMA Town S> pubDate : ', pubDate.toString());
try{
async.mapSeries(srcList,
function(src,cb){
Expand All @@ -129,7 +129,7 @@ kmaTownShortController.prototype.checkPubDate = function(model, srcList, dateStr

for(var i=0 ; i<dbList.length ; i++){
if(dbList[i].pubDate.getTime() === pubDate.getTime()){
log.info('KMA Town S> Already updated : ', src, dateString);
log.debug('KMA Town S> Already updated : ', src, dateString);
return cb(null);
}
}
Expand All @@ -145,8 +145,8 @@ kmaTownShortController.prototype.checkPubDate = function(model, srcList, dateStr
return true;
});

log.info('KMA Town S> Count of the list for the updating : ', result.length);
log.info('KMA Town S> ', JSON.stringify(result));
log.debug('KMA Town S> Count of the list for the updating : ', result.length);
log.debug('KMA Town S> ', JSON.stringify(result));

return callback(errCode, result);
}
Expand Down
22 changes: 11 additions & 11 deletions server/controllers/kma/kma.town.short.rss.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function TownRss(){
self.receivedCount++;

if(self.receivedCount == self.coordDb.length){
log.info('receive complete! : count=', self.receivedCount);
log.debug('receive complete! : count=', self.receivedCount);
}
});

Expand Down Expand Up @@ -91,7 +91,7 @@ TownRss.prototype.loadList = function(completionCallback){
self.coordDb.push(item);
});

log.info('ShortRSS> coord count : ', self.coordDb.length);
log.debug('ShortRSS> coord count : ', self.coordDb.length);
}

if(completionCallback) {
Expand Down Expand Up @@ -236,7 +236,7 @@ TownRss.prototype.convertWeatherString = function(string){
case 'W':
return 8;
default:
log.info('convert : ', string);
log.warn('convertWeatherString > convert : ', string);
return -1;
}
};
Expand Down Expand Up @@ -480,7 +480,7 @@ TownRss.prototype.saveShortRss = function(index, newData, cb){
TownRss.prototype.saveShortRssNewForm = function(index, newData, callback){

var pubDate = kmaTimelib.getKoreaDateObj(newData.pubDate);
log.info('KMA Town S-RSS> pubDate :', pubDate.toString());
log.debug('KMA Town S-RSS> pubDate :', pubDate.toString());
//log.info('KMA Town S-RSS> db find :', coord);


Expand All @@ -494,7 +494,7 @@ TownRss.prototype.saveShortRssNewForm = function(index, newData, callback){
modelKmaTownShortRss.update({mCoord: newData.mCoord, fcsDate: fcsDate}, newItem, {upsert:true}, function(err){
if(err){
log.error('KMA Town S-RSS> Fail to update current item');
log.info(JSON.stringify(newItem));
// log.info(JSON.stringify(newItem));
return cb();
}

Expand Down Expand Up @@ -527,7 +527,7 @@ TownRss.prototype.getShortRssFromDB = function(model, coord, req, callback) {

modelKmaTownShortRss.find({'mCoord.mx': coord.mx, 'mCoord.my': coord.my}, {_id: 0}).sort({"fcsDate":1}).lean().exec(function(err, result){
if(err){
log.info('KMA Town S-RSS> Fail to file&get short data from DB');
log.debug('KMA Town S-RSS> Fail to file&get short data from DB');
log.warn('KMA Town S-RSS> Fail to file&get short data from DB');
return callback(err);
}
Expand All @@ -542,7 +542,7 @@ TownRss.prototype.getShortRssFromDB = function(model, coord, req, callback) {
var ret = [];
var pubDate = kmaTimelib.getKoreaTimeString(result[result.length-1].pubDate);

log.info('KMA Town S-RSS> get Data : ', result.length);
log.debug('KMA Town S-RSS> get Data : ', result.length);
result.forEach(function(item){
var newItem = {};
var shortData = item.shortData;
Expand All @@ -555,7 +555,7 @@ TownRss.prototype.getShortRssFromDB = function(model, coord, req, callback) {
ret.push(newItem);
});

log.info('KMA Town S-RSS> result : ', pubDate);
log.debug('KMA Town S-RSS> result : ', pubDate);
callback(errorNo, {pubDate: pubDate, ret:ret});
}catch(e){
if (callback) {
Expand Down Expand Up @@ -681,14 +681,14 @@ TownRss.prototype.checkPubDate = function(item, dateString, index, callback){
if(err
|| (dbList.length === 0)
|| (dbList[0].pubDate === undefined)){
log.info('KMA Town S-RSS> There is no data matached to : ', item);
log.info('shortRss : get new data : ' + index + ', (' + item.mCoord.mx + ',' + item.mCoord.my + ')');
log.debug('KMA Town S-RSS> There is no data matached to : ', item);
log.debug('shortRss : get new data : ' + index + ', (' + item.mCoord.mx + ',' + item.mCoord.my + ')');
return callback(errCode);
}

for(var i=0 ; i<dbList.length ; i++){
if(dbList[i].pubDate.getTime() === lastestPubDate.getTime()){
log.info('KMA Town S-RSS> Already updated : ', item, dateString);
log.debug('KMA Town S-RSS> Already updated : ', item, dateString);
errCode = 1;
return callback(errCode);
}
Expand Down
10 changes: 5 additions & 5 deletions server/controllers/kma/kma.town.shortest.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ kmaTownShortestController.prototype.getShortestFromDB = function(modelCurrent, c
var ret = [];
var pubDate = kmaTimelib.getKoreaTimeString(result[result.length-1].pubDate);

log.info('KMA Town ST> get Data : ', result.length);
log.debug('KMA Town ST> get Data : ', result.length);
result.forEach(function(item){
var newItem = {};
var shortestData = item.shortestData;
Expand Down Expand Up @@ -113,7 +113,7 @@ kmaTownShortestController.prototype.checkPubDate = function(model, srcList, date
var pubDate = kmaTimelib.getKoreaDateObj(''+ dateString.date + dateString.time);
var errCode = 0;

log.info('KMA Town ST> pubDate : ', pubDate.toString());
log.debug('KMA Town ST> pubDate : ', pubDate.toString());
try{
async.mapSeries(srcList,
function(src,cb){
Expand All @@ -128,7 +128,7 @@ kmaTownShortestController.prototype.checkPubDate = function(model, srcList, date

for(var i=0 ; i<dbList.length ; i++){
if(dbList[i].pubDate.getTime() === pubDate.getTime()){
log.info('KMA Town ST> Already updated : ', src, dateString);
log.debug('KMA Town ST> Already updated : ', src, dateString);
return cb(null);
}
}
Expand All @@ -144,8 +144,8 @@ kmaTownShortestController.prototype.checkPubDate = function(model, srcList, date
return true;
});

log.info('KMA Town ST> Count of the list for the updating : ', result.length);
log.info('KMA Town ST> ', JSON.stringify(result));
log.debug('KMA Town ST> Count of the list for the updating : ', result.length);
log.debug('KMA Town ST> ', JSON.stringify(result));

return callback(errCode, result);
}
Expand Down
Loading