Commit 1554b5d4 authored by Cédric Moreau's avatar Cédric Moreau

Merge branch 'feature/duniter-1.7.x'

parents 6b5a1788 cd15bbdf
......@@ -42,7 +42,8 @@ module.exports = {
},
cliOptions: [
{ value: '--monitor', desc: 'Enable performance monitoring of DB access'}
{ value: '--monitor', desc: 'Enable performance monitoring of DB access'},
{ value: '--reset-data', desc: 'Forces Monit to reset its indexed data on startup'},
],
cli: [{
......
This diff is collapsed.
import {SqliteTable} from "duniter/app/lib/dal/indexDAL/sqlite/SqliteTable";
import {SQLiteDriver} from "duniter/app/lib/dal/drivers/SQLiteDriver";
import {
SqlNotNullableFieldDefinition,
SqlNullableFieldDefinition
} from "duniter/app/lib/dal/indexDAL/sqlite/SqlFieldDefinition";
import {MonitorExecutionTime} from "./MonitorExecutionTime";
import {DBBlock} from "duniter/app/lib/db/DBBlock";
export class SqliteBlockchain extends SqliteTable<MonitDBBlock> {
constructor(getSqliteDB: (dbName: string)=> Promise<SQLiteDriver>) {
super(
'monit',
{
'archived': new SqlNotNullableFieldDefinition('BOOLEAN', true),
'fork': new SqlNotNullableFieldDefinition('BOOLEAN', true),
'hash': new SqlNotNullableFieldDefinition('VARCHAR', false, 64),
'inner_hash': new SqlNotNullableFieldDefinition('VARCHAR', false, 64),
'signature': new SqlNotNullableFieldDefinition('VARCHAR', false, 100),
'currency': new SqlNotNullableFieldDefinition('VARCHAR', false, 50),
'issuer': new SqlNotNullableFieldDefinition('VARCHAR', false, 50),
'version': new SqlNotNullableFieldDefinition('INT', false),
'membersCount': new SqlNotNullableFieldDefinition('INT', false),
'medianTime': new SqlNotNullableFieldDefinition('INT', true), // DATETIME?
'time': new SqlNotNullableFieldDefinition('INT', false), // DATETIME?
'powMin': new SqlNotNullableFieldDefinition('INT', false),
'number': new SqlNotNullableFieldDefinition('INT', false),
'nonce': new SqlNotNullableFieldDefinition('INT', false),
'issuersCount': new SqlNotNullableFieldDefinition('INT', false),
'parameters': new SqlNullableFieldDefinition('VARCHAR', false, 255),
'previousHash': new SqlNullableFieldDefinition('VARCHAR', false, 64),
'previousIssuer': new SqlNullableFieldDefinition('VARCHAR', false, 50),
'monetaryMass': new SqlNullableFieldDefinition('VARCHAR', false, 100),
'UDTime': new SqlNullableFieldDefinition('INT', false), // DATETIME
'dividend': new SqlNullableFieldDefinition('INT', false), // DEFAULT \'0\'
'unitbase': new SqlNullableFieldDefinition('INT', false),
'transactions': new SqlNullableFieldDefinition('TEXT', false),
'certifications': new SqlNullableFieldDefinition('TEXT', false),
'identities': new SqlNullableFieldDefinition('TEXT', false),
'joiners': new SqlNullableFieldDefinition('TEXT', false),
'actives': new SqlNullableFieldDefinition('TEXT', false),
'leavers': new SqlNullableFieldDefinition('TEXT', false),
'revoked': new SqlNullableFieldDefinition('TEXT', false),
'excluded': new SqlNullableFieldDefinition('TEXT', false),
},
getSqliteDB
);
this.name = 'block'
}
@MonitorExecutionTime()
async insertBatch(records: MonitDBBlock[]): Promise<void> {
records.forEach((b:any) => {
for (const prop of ['joiners', 'actives', 'leavers', 'identities', 'certifications', 'transactions', 'revoked', 'excluded']) {
b[prop] = JSON.stringify(b[prop]);
}
return b
});
if (records.length) {
return this.insertBatchInTable(this.driver, records)
}
}
@MonitorExecutionTime()
async query(sql: string, params?: any[]): Promise<any> {
return this.driver.sqlRead(sql, params || [])
}
async getBlock(number: number): Promise<MonitDBBlock|null> {
const blocks = await this.driver.sqlRead('SELECT * FROM block WHERE number = ?', [number])
return blocks.length ? blocks[0] : null
}
async getHighestBlock(): Promise<MonitDBBlock|null> {
const blocks = await this.driver.sqlRead('SELECT * FROM block ORDER BY number DESC LIMIT 1', [])
return blocks.length ? blocks[0] : null
}
async getHighestBlockNumber(): Promise<number> {
const block = await this.getHighestBlock()
return block && block.number || -1
}
async getHighestArchivedBlockNumber(): Promise<number> {
const block = await this.driver.sqlRead('SELECT * FROM block WHERE archived ORDER BY number DESC LIMIT 1', [])
return block.length && block[0].number || -1
}
trimNonArchived() {
return this.driver.sqlWrite('DELETE FROM block WHERE NOT archived', [])
}
setArchived(currentCeil: number) {
return this.driver.sqlWrite('UPDATE block SET archived = ? WHERE number <= ? AND NOT archived', [true, currentCeil])
}
deleteAll() {
return this.driver.sqlWrite('DELETE FROM block', [])
}
}
export interface MonitDBBlock extends DBBlock {
archived: boolean
}
"use strict";
module.exports = {
export const MonitConstants = {
USE_WOTB6: false,
DEFAULT_LANGUAGE: "fr",
MIN_WILLMEMBERS_UPDATE_FREQ: 180,
......@@ -16,4 +14,4 @@ module.exports = {
GET_SENTRIES_COUNT: 3,
GET_D_SEN: 3
}
};
\ No newline at end of file
};
......@@ -4,7 +4,7 @@ const co = require('co');
const os = require('os');
const fs = require('fs');
const webserver = require(__dirname + '/webserver.js');
const webserver = require(__dirname + '/webserver2.js');
const timestampToDatetime = require(__dirname + '/timestampToDatetime.js');
/****************************
......@@ -48,7 +48,7 @@ module.exports = (duniterServer, host, port, appParente, program) => co(function
console.log("module currency-monit started");
// Specialized node's UI
let httpServer = webserver(host, port, appParente, duniterServer, monitDatasPath, offset, cache);
let httpServer = webserver(host, port, appParente, duniterServer, monitDatasPath, offset, cache, program.resetData);
yield httpServer.openConnection();
})
......
......@@ -2,9 +2,10 @@
import {DataFinder} from "./DataFinder";
import {DBBlock} from "duniter/app/lib/db/DBBlock";
import {MonitConstants} from "./constants2";
import {Server} from "duniter/server";
const co = require('co');
const constants = require(__dirname + '/constants')
/**
* updateCache
......@@ -12,9 +13,9 @@ const constants = require(__dirname + '/constants')
*/
module.exports = async (req:any, res:any, next:any) => {
var { duniterServer, cache } = req.app.locals
var { duniterServer, cache } = req.app.locals as { duniterServer: Server, cache: MonitCache };
const dataFinder = new DataFinder(duniterServer)
const dataFinder = await DataFinder.getInstanceReindexedIfNecessary()
try {
// Définition des constantes
......@@ -24,7 +25,7 @@ module.exports = async (req:any, res:any, next:any) => {
let upgradeCache = false;
// Cacluler s'il faut mettre à jour le cache ou pas
upgradeCache = (Math.floor(Date.now() / 1000) > (cache.lastUptime + constants.MIN_CACHE_UPDATE_FREQ));
upgradeCache = (Math.floor(Date.now() / 1000) > (cache.lastUptime + MonitConstants.MIN_CACHE_UPDATE_FREQ));
// Si le cache membersCount est dévérouillé, le vérouiller, sinon ne pas réinitialiser le cache
if (upgradeCache && !cache.lockMembersCount)
......@@ -109,8 +110,8 @@ module.exports = async (req:any, res:any, next:any) => {
{ cache.beginBlock = [await dataFinder.getBlock(0)]; }
else if (req.query.begin > cache.endBlock[0].number)
{
let beginTime = cache.endBlock[0].medianTime-(parseInt(cache.step)*unitTime*constants.STEP_COUNT_MIN);
cache.beginBlock = [await dataFinder.getBlockWhereMedianTimeGte(beginTime)];
let beginTime = cache.endBlock[0].medianTime-(parseInt(cache.step)*unitTime*MonitConstants.STEP_COUNT_MIN);
cache.beginBlock = await dataFinder.getBlockWhereMedianTimeGte(beginTime);
}
else { cache.beginBlock = [await dataFinder.getBlock(req.query.begin)]; }
......@@ -118,34 +119,36 @@ module.exports = async (req:any, res:any, next:any) => {
if ( typeof(req.query.nbMaxPoints) != 'undefined' && req.query.nbMaxPoints > 0 ) {
cache.nbMaxPoints = req.query.nbMaxPoints;
} else {
cache.nbMaxPoints = constants.STEP_COUNT_MAX;
cache.nbMaxPoints = MonitConstants.STEP_COUNT_MAX;
}
if ( typeof(req.query.adaptMaxPoints) != 'undefined' && (req.query.adaptMaxPoints == "step" || req.query.adaptMaxPoints == "end")) {
cache.adaptMaxPoints = req.query.adaptMaxPoints;
} else {
cache.adaptMaxPoints = "begin";
}
if (!cache.beginBlock || !cache.beginBlock[0]) {
throw Error("No begin block")
}
// Apply nbMaxPoints and adaptMaxPoints
if (cache.adaptMaxPoints == "begin")
{
if ( Math.ceil((cache.endBlock[0].medianTime-cache.beginBlock[0].medianTime)/(cache.step*unitTime)) > cache.nbMaxPoints )
{
let newBeginTime = cache.endBlock[0].medianTime-cache.step*cache.nbMaxPoints*unitTime;
cache.beginBlock = [await dataFinder.getBlockWhereMedianTimeGte(newBeginTime)];
cache.beginBlock = await dataFinder.getBlockWhereMedianTimeGte(newBeginTime);
}
} else if (cache.adaptMaxPoints == "step") {
cache.step = Math.ceil((cache.endBlock[0].medianTime-cache.beginBlock[0].medianTime)/(constants.STEP_COUNT_MAX*unitTime));
cache.step = Math.ceil((cache.endBlock[0].medianTime-cache.beginBlock[0].medianTime)/(MonitConstants.STEP_COUNT_MAX*unitTime));
} else {
let newEndTime = cache.beginBlock[0].medianTime+cache.step*cache.nbMaxPoints*unitTime;
cache.endBlock = [await dataFinder.getBlockWhereMedianTimeLte(newEndTime)];
cache.endBlock = await dataFinder.getBlockWhereMedianTimeLte(newEndTime);
}
// Calculate stepTime
cache.stepTime = parseInt(cache.step)*unitTime;
// if new blocks and MIN_CACHE_UPDATE_FREQ pass, update cache
if ( parseInt(cache.endBlock[0].number) >= cache.currentBlockNumber && Math.floor(Date.now() / 1000) > (cache.lastUptime + constants.MIN_CACHE_UPDATE_FREQ))
if ( parseInt(cache.endBlock[0].number) >= cache.currentBlockNumber && Math.floor(Date.now() / 1000) > (cache.lastUptime + MonitConstants.MIN_CACHE_UPDATE_FREQ))
{
// let previousCacheTime = (cache.blockchain.length > 0) ? cache.blockchain[cache.blockchain.length-1].medianTime:0;
var newBlocks = await dataFinder.getBlockWhereMedianTimeLteAndGtNoLimit(cache.currentBlockTime, cache.endBlock[0].medianTime);
......@@ -293,3 +296,7 @@ module.exports = async (req:any, res:any, next:any) => {
}
}
interface MonitCache {
[k: string]: any
beginBlock: null|DBBlock[]
}
"use strict";
import {Server} from "duniter/server";
import {initMonitDB} from "./DataFinder";
const fs = require('fs');
//const util = require('util');
const Q = require('q');
......@@ -13,13 +16,13 @@ const bodyParser = require('body-parser');
const routes = require(__dirname + '/../routes');
const tpl = require(__dirname + '/tplit.js');
module.exports = (host, port, appParente, duniterServer, monitDatasPath, offset, cache) => {
module.exports = (host: any, port: any, appParente: any, duniterServer: Server, monitDatasPath: any, offset: any, cache: any, resetData: boolean) => {
var app = express();
app.use(morgan('\x1b[90m:remote-addr :remote-user [:date[clf]] :method :url HTTP/:http-version :status :res[content-length] - :response-time ms\x1b[0m', {
stream: {
write: function(message){
write: function(message: any){
message && console.log(message.replace(/\n$/,''));
}
}
......@@ -44,7 +47,7 @@ module.exports = (host, port, appParente, duniterServer, monitDatasPath, offset,
/***************************************
* CSV des membres calculants
***************************************/
app.get('/csvCalculatorsRank', function(req, res) {
app.get('/csvCalculatorsRank', function(req: any, res: any) {
let files = fs.readdirSync(monitDatasPath + '/calculators_rank/')
let maxTimestamp = 0
for (let file of files) {
......@@ -61,35 +64,46 @@ module.exports = (host, port, appParente, duniterServer, monitDatasPath, offset,
if ( appParente == null )
{
let httpServer = http.createServer(app);
httpServer.on('error', function(err) {
httpServer.on('error', function(err: any) {
httpServer.errorPropagates(err);
});
return {
openConnection: () => co(function *() {
try {
yield Q.Promise((resolve, reject) => {
// Weird the need of such a hack to catch an exception...
httpServer.errorPropagates = function(err) {
reject(err);
};
openConnection: async () => {
try {
await Q.Promise((resolve: any, reject: any) => {
// Weird the need of such a hack to catch an exception...
httpServer.errorPropagates = function(err: any) {
reject(err);
};
httpServer.listen(port, host, (err: any) => {
if (err) return reject(err);
resolve(httpServer);
});
});
// Init + first incremental indexation
await initMonitDB(duniterServer, resetData)
console.log('Server listening on http://' + host + ':' + port);
httpServer.listen(port, host, (err) => {
if (err) return reject(err);
resolve(httpServer);
});
});
console.log('Server listening on http://' + host + ':' + port);
} catch (e) {
console.warn('Could NOT listen to http://' + host + ':' + port);
console.warn(e);
}
}),
} catch (e) {
console.warn('Could NOT listen to http://' + host + ':' + port);
console.warn(e);
}
},
};
}
else
{
appParente.use("/currency-monit", app);
return {
openConnection: async () => {
console.log('No connection to open')
}
};
}
......
......@@ -4,7 +4,8 @@
"main": "index.js",
"license": "AGPLv3",
"scripts": {
"prepublish": "tsc"
"prepublish": "tsc",
"test": "mocha"
},
"dependencies": {
"body-parser": "1.17.1",
......@@ -21,10 +22,14 @@
},
"devDependencies": {
"@types/node": "^11.9.3",
"duniter": "1.6.x",
"typescript": "^3.3.3"
"@types/mocha": "^2.2.41",
"duniter": "1.7.x",
"typescript": "^3.3.3",
"mocha": "^3.4.2",
"should": "*",
"ts-node": "^3.3.0"
},
"peerDependencies": {
"duniter": "^1.6.21"
"duniter": "1.7.x"
}
}
import {DBBlock} from 'duniter/app/lib/db/DBBlock'
import {DataFinder} from '../lib/DataFinder'
import {showExecutionTimes} from '../lib/MonitorExecutionTime'
import {MonitConstants} from "../lib/constants2";
const fs = require('fs')
const timestampToDatetime = require(__dirname + '/../lib/timestampToDatetime')
const colorScale = require(__dirname + '/../lib/colorScale')
const getLang = require(__dirname + '/../lib/getLang')
const constants = require(__dirname + '/../lib/constants')
// Garder l'index des blocs en mémoire vive
var blockchain: DBBlock[] = [];
......@@ -15,9 +15,9 @@ var previousBlockchainTime= 0;
module.exports = async (req: any, res: any, next: any) => {
var { duniterServer, monitDatasPath } = req.app.locals
var { monitDatasPath } = req.app.locals
const dataFinder = new DataFinder(duniterServer)
const dataFinder = await DataFinder.getInstanceReindexedIfNecessary()
try {
// get GET parameters
......@@ -30,7 +30,7 @@ module.exports = async (req: any, res: any, next: any) => {
var significantPercent = req.query.significantPercent || 3;
// get lg file
const LANG = getLang(`${__dirname}/../lg/blockCount_${req.query.lg||constants.DEFAULT_LANGUAGE}.txt`);
const LANG = getLang(`${__dirname}/../lg/blockCount_${req.query.lg||MonitConstants.DEFAULT_LANGUAGE}.txt`);
// detect fork
if ( blockchain.length > 0 )
......
"use strict";
import {DataFinder} from "../lib/DataFinder";
import {MonitConstants} from "../lib/constants2";
const co = require('co')
const constants = require(__dirname + '/../lib/constants')
const membersQuality = require(__dirname + '/tools/membersQuality')
const getLang = require(__dirname + '/../lib/getLang')
......@@ -15,7 +11,7 @@ module.exports = async (req:any, res:any, next:any) => {
var { duniterServer } = req.app.locals
const dataFinder = new DataFinder(duniterServer)
const dataFinder = await DataFinder.getInstanceReindexedIfNecessary()
try {
// get GET parameters
......@@ -25,14 +21,14 @@ module.exports = async (req:any, res:any, next:any) => {
const nextYn = (req.query.nextYn=="yes") ? "yes":"no";
// get lg file
const LANG = getLang(`${__dirname}/../lg/gaussianWotQuality_${req.query.lg||constants.DEFAULT_LANGUAGE}.txt`);
const LANG = getLang(`${__dirname}/../lg/gaussianWotQuality_${req.query.lg||MonitConstants.DEFAULT_LANGUAGE}.txt`);
// Définition des contantes
const conf = duniterServer.conf;
const qualityMax = (1/conf.xpercent);
// Définition des variables
let lastUpgradeTimeDatas = membersQuality(constants.QUALITY_CACHE_ACTION.INIT);
let lastUpgradeTimeDatas = membersQuality(MonitConstants.QUALITY_CACHE_ACTION.INIT);
let tabUidIndex = [];
let tabMembersQuality= [];
let tabMembersQualitySorted = [];
......@@ -44,7 +40,7 @@ module.exports = async (req:any, res:any, next:any) => {
let membersList = await dataFinder.getMembers();
// Si les données de qualité n'ont jamais été calculés, le faire
if (lastUpgradeTimeDatas == 0 || (lastUpgradeTimeDatas+constants.MIN_WOT_QUALITY_CACHE_UPDATE_FREQ) < (Math.floor(Date.now() / 1000)) || (previousNextYn != nextYn))
if (lastUpgradeTimeDatas == 0 || (lastUpgradeTimeDatas+MonitConstants.MIN_WOT_QUALITY_CACHE_UPDATE_FREQ) < (Math.floor(Date.now() / 1000)) || (previousNextYn != nextYn))
{
// Calculer dSen
var dSen = Math.ceil(Math.pow(membersList.length, 1 / conf.stepMax));
......@@ -54,14 +50,14 @@ module.exports = async (req:any, res:any, next:any) => {
const wot = duniterServer.dal.wotb;
// Initialiser le cache des données de qualité
membersQuality(constants.QUALITY_CACHE_ACTION.INIT, 0, dSen, conf.stepMax, conf.xpercent, wot.memCopy());
membersQuality(MonitConstants.QUALITY_CACHE_ACTION.INIT, 0, dSen, conf.stepMax, conf.xpercent, wot.memCopy());
}
// Mettre a jour previousNextYn
previousNextYn = (nextYn=="yes") ? "yes":"no";
// Calculer nbSentries, limit1 and label
const nbSentries = (sentries=="no") ? membersList.length:membersQuality(constants.QUALITY_CACHE_ACTION.GET_SENTRIES_COUNT);
const nbSentries = (sentries=="no") ? membersList.length:membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_SENTRIES_COUNT);
let limit1 = 1;
let label = LANG['QUALITY'];
switch (unit)
......@@ -80,15 +76,15 @@ module.exports = async (req:any, res:any, next:any) => {
// Récupérer le tableau de qualité des membres
tabMembersQuality= [];
for (let i=0;membersQuality(constants.QUALITY_CACHE_ACTION.GET_QUALITY, i) >= 0;i++)
for (let i=0; i < membersList.length && membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_QUALITY, i) >= 0;i++)
{
if (sentries == "no")
{
tabMembersQuality[i] = membersQuality(constants.QUALITY_CACHE_ACTION.GET_QUALITY, i, -1);
tabMembersQuality[i] = membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_QUALITY, i, -1);
}
else
{
tabMembersQuality[i] = membersQuality(constants.QUALITY_CACHE_ACTION.GET_QUALITY, i);
tabMembersQuality[i] = membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_QUALITY, i);
}
}
......
const fs = require('fs')
const express = require('express')
const constants = require(__dirname + '/../lib/constants')
const constants = require(__dirname + '/../lib/constants2').MonitConstants
const getLang = require(__dirname + '/../lib/getLang')
const printMenu = require(__dirname + '/../views/printMenu')
......
import {DataFinder} from '../lib/DataFinder'
import {MonitConstants} from "../lib/constants2";
const constants = require(__dirname + '/../lib/constants')
const randomInt = require(__dirname + '/../lib/randomInt')
const timestampToDatetime = require(__dirname + '/../lib/timestampToDatetime')
const membersQuality = require(__dirname + '/tools/membersQuality')
......@@ -45,7 +45,7 @@ module.exports = async (req: any, res: any, next: any) => {
var { duniterServer } = req.app.locals
const dataFinder = new DataFinder(duniterServer)
const dataFinder = await DataFinder.getInstanceReindexedIfNecessary()
try {
// Initaliser les constantes
......@@ -74,15 +74,15 @@ module.exports = async (req: any, res: any, next: any) => {
let numberOfRandomMembers = req.query.randomCounts || 10
// Vérifier la valeur de nextYn dans le cache
let lastUpgradeTimeDatas = membersQuality(constants.QUALITY_CACHE_ACTION.INIT);
let dSenCache = membersQuality(constants.QUALITY_CACHE_ACTION.GET_D_SEN);
let lastUpgradeTimeDatas = membersQuality(MonitConstants.QUALITY_CACHE_ACTION.INIT);
let dSenCache = membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_D_SEN);
if (lastUpgradeTimeDatas > 0 && dSenCache > dSen) { previousNextYn == "yes"; }
// Alimenter wotb avec la toile actuelle
const wotbInstance = duniterServer.dal.wotb;
// Vérifier si le cache doit être Réinitialiser
let reinitCache = (Math.floor(Date.now() / 1000) > (membersLastUptime + constants.MIN_MEMBERS_UPDATE_FREQ));
let reinitCache = (Math.floor(Date.now() / 1000) > (membersLastUptime + MonitConstants.MIN_MEMBERS_UPDATE_FREQ));
// Si changement de conditions, alors forcer le rechargement du cache s'il n'est pas vérouillé, sinon forcer les conditions à celles en mémoire
if (previousMode != mode || previousCentrality != centrality || previousNextYn != nextYn || previousRandomList != randomList || numberOfRandomMembers != previousRandomCounts)
......@@ -145,7 +145,7 @@ module.exports = async (req: any, res: any, next: any) => {
if (nextYn=="yes") { dSen++; }
// réinitialiser le cache des données de qualité
membersQuality(constants.QUALITY_CACHE_ACTION.INIT, 0, dSen, conf.stepMax, conf.xpercent, wotbInstance.memCopy());
membersQuality(MonitConstants.QUALITY_CACHE_ACTION.INIT, 0, dSen, conf.stepMax, conf.xpercent, wotbInstance.memCopy());
// Réinitialiser le cache des données de centralité
if (centrality=='yes')
......@@ -181,7 +181,7 @@ module.exports = async (req: any, res: any, next: any) => {
for (let m=0;m<membersList.length;m++)
{
// Récupérer les blockstamp d'écriture et date d'expiration du membership courant du membre m
let tmpQueryResult = await dataFinder.membershipWrittenOnExpiresOn(membersList[m].pub);
let tmpQueryResult = [await dataFinder.membershipWrittenOnExpiresOn(membersList[m].pub)];
membershipsExpireTimeList.push(tmpQueryResult[0].expires_on);
// Extraire le numéro de bloc du blockstamp d'écriture du membership courant
......@@ -229,14 +229,14 @@ module.exports = async (req: any, res: any, next: any) => {
membersNbSentriesUnreached[membersList[m].uid] = parseInt(detailedDistance.nbSentries) - parseInt(detailedDistance.nbSuccess);
// Calculer la qualité du membre courant
if (membersQuality(constants.QUALITY_CACHE_ACTION.GET_QUALITY, membersList[m].wotb_id, (currentMemberIsSentry) ? 1 : 0) >= 1.0) {
if (membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_QUALITY, membersList[m].wotb_id, (currentMemberIsSentry) ? 1 : 0) >= 1.0) {
proportionMembersWithQualityUpper1++;
}
// Calculer la qualité du membre courant s'il n'y avait pas de référents (autrement di si tout les membres était référents)
//let membersQualityIfNoSentries = ((detailedDistanceQualityExt.nbReached/membersList.length)/conf.xpercent).toFixed(2);
//console.log("membersQualityIfNoSentries[%s] = %s", membersList[m].uid, membersQualityIfNoSentries);
if (membersQuality(constants.QUALITY_CACHE_ACTION.GET_QUALITY, membersList[m].wotb_id, -1) >= 1.0) {
if (membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_QUALITY, membersList[m].wotb_id, -1) >= 1.0) {
proportionMembersWithQualityUpper1IfNoSentries++;
}
......@@ -274,11 +274,11 @@ module.exports = async (req: any, res: any, next: any) => {
let tmpQueryGetUidProtagonistCert
if (mode == 'emitted')
{
tmpQueryGetUidProtagonistCert = await dataFinder.getProtagonist(tmpQueryCertifsList[i].receiver)
tmpQueryGetUidProtagonistCert = [await dataFinder.getProtagonist(tmpQueryCertifsList[i].receiver)]
}
else
{
tmpQueryGetUidProtagonistCert = await dataFinder.getProtagonist(tmpQueryCertifsList[i].issuer)
tmpQueryGetUidProtagonistCert = [await dataFinder.getProtagonist(tmpQueryCertifsList[i].issuer)]
}
let tmpBlockWrittenOn = tmpQueryCertifsList[i].written_on.split("-");
......@@ -474,7 +474,7 @@ module.exports = async (req: any, res: any, next: any) => {
{
for (const member of membersList)
{
tabSort.push(membersQuality(constants.QUALITY_CACHE_ACTION.GET_QUALITY, member.wotb_id));
tabSort.push(membersQuality(MonitConstants.QUALITY_CACHE_ACTION.GET_QUALITY, member.wotb_id));
}
}
else if (sort_by == "sigCount")
......@@ -574,7 +574,7 @@ module.exports = async (req: any, res: any, next: any) => {
// Sinon, printer le tableau html
else