Browse Source

added shepherd cache call status

all-modes
Petr Balashov 8 years ago
parent
commit
88dc21395a
  1. 27
      gui/loading.js
  2. 42
      routes/shepherd.js

27
gui/loading.js

@ -18,18 +18,18 @@ function Iguana_activehandle(callback) {
'method': 'activehandle'
},
AjaxOutputData = IguanaAJAX('http://127.0.0.1:7778', ajax_data).done(function(data) {
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
//console.log(AjaxOutputData.responseText);
AjaxOutputData = JSON.parse(AjaxOutputData.responseText)
//console.log(AjaxOutputData);
resolve(AjaxOutputData);
}).fail(function(xhr, textStatus, error) {
// handle request failures
console.log(xhr.statusText);
if ( xhr.readyState == 0 ) {
}
console.log(textStatus);
console.log(error);
});
});
}
//Iguana_activehandle().then(function(result){
@ -70,7 +70,8 @@ function GetAppConf() { // get iguana app conf
async: false,
type: 'GET',
url: 'http://127.0.0.1:17777/shepherd/appconf'
}).done(function(_data) {
})
.done(function(_data) {
console.log('== App Conf Data OutPut ==');
console.log(_data);
data = _data;

42
routes/shepherd.js

@ -252,14 +252,27 @@ shepherd.get('/cache-all', function(req, res, next) {
outObj.basilisk[coin][address] = {};
writeCache();
// set current call status
async.forEachOf(dexUrls, function(dexUrl, key) {
if (!outObj.basilisk[coin][address][key]) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].status = 'waiting';
} else {
outObj.basilisk[coin][address][key].status = 'waiting';
}
});
writeCache();
async.forEachOf(dexUrls, function(dexUrl, key) {
var tooEarly = false;
if (outObj.basilisk[coin][address][key] &&
outObj.basilisk[coin][address][key].timestamp &&
checkTimestamp(outObj.basilisk[coin][address][key].timestamp) < cacheGlobLifetime) {
tooEarly = true;
outObj.basilisk[coin][address][key].status = 'done';
}
if (!tooEarly) {
outObj.basilisk[coin][address][key].status = 'in progress';
request({
url: dexUrl,
method: 'GET'
@ -268,6 +281,7 @@ shepherd.get('/cache-all', function(req, res, next) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].data = JSON.parse(body);
outObj.basilisk[coin][address][key].timestamp = Date.now(); // add timestamp
outObj.basilisk[coin][address][key].status = 'done';
console.log(dexUrl);
console.log(body);
callStack[coin]--;
@ -450,14 +464,27 @@ shepherd.get('/cache-one', function(req, res, next) {
writeCache();
}
// set current call status
async.forEachOf(_dexUrls, function(dexUrl, key) {
if (!outObj.basilisk[coin][address][key]) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].status = 'waiting';
} else {
outObj.basilisk[coin][address][key].status = 'waiting';
}
});
writeCache();
async.forEachOf(_dexUrls, function(dexUrl, key) {
var tooEarly = false;
if (outObj.basilisk[coin][address][key] &&
outObj.basilisk[coin][address][key].timestamp &&
checkTimestamp(outObj.basilisk[coin][address][key].timestamp) < cacheGlobLifetime) {
tooEarly = true;
outObj.basilisk[coin][address][key].status = 'done';
}
if (!tooEarly) {
outObj.basilisk[coin][address][key].status = 'in progress';
request({
url: dexUrl,
method: 'GET'
@ -466,6 +493,7 @@ shepherd.get('/cache-one', function(req, res, next) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].data = JSON.parse(body);
outObj.basilisk[coin][address][key].timestamp = Date.now(); // add timestamp
outObj.basilisk[coin][address][key].status = 'done';
console.log(dexUrl);
console.log(body);
callStack[coin]--;
@ -514,14 +542,27 @@ shepherd.get('/cache-one', function(req, res, next) {
}
console.log(_dexUrls);
// set current call status
async.forEachOf(_dexUrls, function(dexUrl, key) {
if (!outObj.basilisk[coin][address][key]) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].status = 'waiting';
} else {
outObj.basilisk[coin][address][key].status = 'waiting';
}
});
writeCache();
async.forEachOf(_dexUrls, function(dexUrl, key) {
var tooEarly = false;
if (outObj.basilisk[coin][address][key] &&
outObj.basilisk[coin][address][key].timestamp &&
checkTimestamp(outObj.basilisk[coin][address][key].timestamp) < cacheGlobLifetime) {
tooEarly = true;
outObj.basilisk[coin][address][key].status = 'done';
}
if (!tooEarly) {
outObj.basilisk[coin][address][key].status = 'in progress';
request({
url: dexUrl,
method: 'GET'
@ -530,6 +571,7 @@ shepherd.get('/cache-one', function(req, res, next) {
outObj.basilisk[coin][address][key] = {};
outObj.basilisk[coin][address][key].data = JSON.parse(body);
outObj.basilisk[coin][address][key].timestamp = Date.now(); // add timestamp
outObj.basilisk[coin][address][key].status = 'done';
console.log(dexUrl);
console.log(body);
callStack[coin]--;

Loading…
Cancel
Save