Skip to content
Snippets Groups Projects
Commit 4ac3d030 authored by Éloïs's avatar Éloïs
Browse files

[fix] fix #44

parent 66e87ed1
No related branches found
No related tags found
1 merge request!55Dev module
LAST_BLOCK last block
BEGIN Begin BEGIN Begin
END End END End
STEP step STEP step
......
LAST_BLOCK dernier bloc
BEGIN Début BEGIN Début
END Fin END Fin
STEP précision STEP précision
......
...@@ -108,7 +108,7 @@ module.exports = (req, res, next) => co(function *() { ...@@ -108,7 +108,7 @@ module.exports = (req, res, next) => co(function *() {
{ {
case "blocks": unitTime = 3600; cache.onlyDate = false; cache.stepUnit = "blocks"; break; case "blocks": unitTime = 3600; cache.onlyDate = false; cache.stepUnit = "blocks"; break;
case "hours": unitTime = 3600; cache.onlyDate = false; cache.stepUnit = "hours"; break; case "hours": unitTime = 3600; cache.onlyDate = false; cache.stepUnit = "hours"; break;
case "days": unitTime = 86400; cache.onlyDate = false; cache.stepUnit = "days"; break; case "days": unitTime = 86400; cache.onlyDate = true; cache.stepUnit = "days"; break;
case "weeks": unitTime = 604800; cache.onlyDate = true; cache.stepUnit = "weeks"; break; case "weeks": unitTime = 604800; cache.onlyDate = true; cache.stepUnit = "weeks"; break;
case "months": unitTime = 18144000; cache.onlyDate = true; cache.stepUnit = "months"; break; case "months": unitTime = 18144000; cache.onlyDate = true; cache.stepUnit = "months"; break;
case "years": unitTime = 31557600; cache.onlyDate = true; cache.stepUnit = "years"; break; case "years": unitTime = 31557600; cache.onlyDate = true; cache.stepUnit = "years"; break;
...@@ -117,7 +117,7 @@ module.exports = (req, res, next) => co(function *() { ...@@ -117,7 +117,7 @@ module.exports = (req, res, next) => co(function *() {
// Default values // Default values
else else
{ {
unitTime = 86400; cache.onlyDate = false; cache.stepUnit = "days"; unitTime = 86400; cache.onlyDate = true; cache.stepUnit = "days";
} }
// get endBlock // get endBlock
......
...@@ -14,6 +14,9 @@ module.exports = (req, res, next) => co(function *() { ...@@ -14,6 +14,9 @@ module.exports = (req, res, next) => co(function *() {
// get GET parameters // get GET parameters
var format = req.query.format || 'HTML'; var format = req.query.format || 'HTML';
// get lg file
const LANG = getLang(`${__dirname}/../lg/membersCount_${req.query.lg||'fr'}.txt`);
// get medianTime of beginBlock // get medianTime of beginBlock
var beginBlock = yield duniterServer.dal.peerDAL.query('SELECT `medianTime`,`hash` FROM block WHERE `fork`=0 AND `number` = '+cache.beginBlock[0].number+' LIMIT 1'); var beginBlock = yield duniterServer.dal.peerDAL.query('SELECT `medianTime`,`hash` FROM block WHERE `fork`=0 AND `number` = '+cache.beginBlock[0].number+' LIMIT 1');
...@@ -32,7 +35,7 @@ module.exports = (req, res, next) => co(function *() { ...@@ -32,7 +35,7 @@ module.exports = (req, res, next) => co(function *() {
} }
// Initialize nextStepTime, stepIssuerCount and bStep // Initialize nextStepTime, stepIssuerCount and bStep
var nextStepTime = blockchain[0].medianTime; var nextStepTime = blockchain[0].medianTime - (blockchain[0].medianTime % 86400);
let stepIssuerCount = 0; let stepIssuerCount = 0;
let bStep = 0; let bStep = 0;
...@@ -53,7 +56,7 @@ module.exports = (req, res, next) => co(function *() { ...@@ -53,7 +56,7 @@ module.exports = (req, res, next) => co(function *() {
tabMembersCount.push({ tabMembersCount.push({
blockNumber: blockchain[b].number, blockNumber: blockchain[b].number,
timestamp: blockchain[b].medianTime, timestamp: blockchain[b].medianTime,
dateTime: timestampToDatetime(blockchain[b].medianTime), dateTime: timestampToDatetime(blockchain[b].medianTime, cache.onlyDate),
membersCount: blockchain[b].membersCount, membersCount: blockchain[b].membersCount,
sentriesCount: cache.blockchain[cacheIndex].sentries, sentriesCount: cache.blockchain[cacheIndex].sentries,
issuersCount: parseInt(stepIssuerCount/bStep) issuersCount: parseInt(stepIssuerCount/bStep)
...@@ -69,7 +72,7 @@ module.exports = (req, res, next) => co(function *() { ...@@ -69,7 +72,7 @@ module.exports = (req, res, next) => co(function *() {
tabMembersCount.push({ tabMembersCount.push({
blockNumber: blockchain[blockchain.length-1].number, blockNumber: blockchain[blockchain.length-1].number,
timestamp: blockchain[blockchain.length-1].medianTime, timestamp: blockchain[blockchain.length-1].medianTime,
dateTime: timestampToDatetime(blockchain[blockchain.length-1].medianTime), dateTime: LANG['LAST_BLOCK'],
membersCount: blockchain[blockchain.length-1].membersCount, membersCount: blockchain[blockchain.length-1].membersCount,
sentriesCount: cache.blockchain[cache.blockchain.length-1].sentries, sentriesCount: cache.blockchain[cache.blockchain.length-1].sentries,
issuersCount: blockchain[blockchain.length-1].issuersCount issuersCount: blockchain[blockchain.length-1].issuersCount
...@@ -79,9 +82,6 @@ module.exports = (req, res, next) => co(function *() { ...@@ -79,9 +82,6 @@ module.exports = (req, res, next) => co(function *() {
res.status(200).jsonp( tabMembersCount ) res.status(200).jsonp( tabMembersCount )
else else
{ {
// get lg file
const LANG = getLang(`${__dirname}/../lg/membersCount_${req.query.lg||'fr'}.txt`);
// GET parameters // GET parameters
var unit = req.query.unit == 'relative' ? 'relative' : 'quantitative'; var unit = req.query.unit == 'relative' ? 'relative' : 'quantitative';
var massByMembers = req.query.massByMembers == 'no' ? 'no' : 'yes'; var massByMembers = req.query.massByMembers == 'no' ? 'no' : 'yes';
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment