Commit 590dd993 authored by Cédric Moreau's avatar Cédric Moreau

Merge branch 'feature/members'

parents e9b2c32d 6beca2f2
Pipeline #8718 passed with stage
in 34 seconds
......@@ -67,4 +67,7 @@ NEXT_YN Feign the following Y[n] landing
MEMBER_FILTER search a member
EXPIRE_TIME expiration datetime
RANDOM_LIST Draw lots
MEMBERS members
\ No newline at end of file
RANDOM_LIST_END membres (max. 100)
MEMBERS members
UID_OR_PUB_LIST Whose pseudo or key contains
UID_OR_PUB_LIST_END (3 chars. min.)
......@@ -67,4 +67,7 @@ NEXT_YN Simuler le palier Y[n] suivant
MEMBER_FILTER rechercher un membre
EXPIRE_TIME date et heure d'expiration
RANDOM_LIST Tirer au sort
MEMBERS membres
\ No newline at end of file
RANDOM_LIST_END membres (max. 100)
MEMBERS membres
UID_OR_PUB_LIST Dont le pseudo ou la clé contient
UID_OR_PUB_LIST_END (3 car. min.)
......@@ -13,5 +13,9 @@ export const MonitConstants = {
INIT: 2,
GET_SENTRIES_COUNT: 3,
GET_D_SEN: 3
}
},
MEMBERS_VIEW: {
DEFAULT_MEMBERS_RANDOM_NUMBER: 10,
MEMBERS_DISPLAY_MAX: 100,
},
};
......@@ -69,15 +69,36 @@ module.exports = async (req: any, res: any, next: any) => {
var pendingSigs = req.query.pendingSigs || "no"; // Valeur par défaut
var centrality = req.query.centrality || "no"; // Valeur par défaut
var format = req.query.format || 'HTML'; // Valeur par défaut
let uidOrPubList = req.query.uidOrPubList === 'yes';
let uidOrPubValue = req.query.uidOrPubValue;
let nextYn = (req.query.nextYn=="yes") ? "yes":"no";
let randomList = (req.query.randomList=="yes") ? "yes":"no";
let numberOfRandomMembers = req.query.randomCounts || 10
let randomList = req.query.randomList === 'no' ? 'no' : 'yes';
let numberOfRandomMembers = parseInt(req.query.randomCounts) || MonitConstants.MEMBERS_VIEW.DEFAULT_MEMBERS_RANDOM_NUMBER
// Recherche aléatoire
if (randomList === 'yes') {
if (isNaN(numberOfRandomMembers)) {
numberOfRandomMembers = MonitConstants.MEMBERS_VIEW.DEFAULT_MEMBERS_RANDOM_NUMBER
}
numberOfRandomMembers = Math.min(numberOfRandomMembers, MonitConstants.MEMBERS_VIEW.MEMBERS_DISPLAY_MAX)
}
// Vérifier la valeur de nextYn dans le cache
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"; }
// Recherche par pseudo/pubkey
if (uidOrPubList) {
// UID/PUB > random
randomList = 'no'
if (!uidOrPubValue || uidOrPubValue.length < 3) {
// Recherche trop large
uidOrPubList = false
randomList = 'yes' // A la place
}
}
// Alimenter wotb avec la toile actuelle
const wotbInstance = duniterServer.dal.wotb;
......@@ -85,7 +106,8 @@ module.exports = async (req: any, res: any, next: any) => {
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)
// Si recherche par UID ou pubkey => recharger systématiquement
if (uidOrPubList || previousMode != mode || previousCentrality != centrality || previousNextYn != nextYn || previousRandomList != randomList || numberOfRandomMembers != previousRandomCounts)
{
if (!lockMembers)
{
......@@ -175,6 +197,12 @@ module.exports = async (req: any, res: any, next: any) => {
}
membersList = randomMembers
}
else if (uidOrPubList) {
// Rerchercher les membres qui matchent par l'UID ou la pubkey
membersList = membersList.filter(m => {
return m.uid.toLocaleLowerCase().includes(uidOrPubValue) || m.pub.toLocaleLowerCase().includes(uidOrPubValue)
})
}
// Récupérer pour chaque identité, le numéro du block d'écriture du dernier membership
// Ainsi que la première ou dernière certification
......@@ -581,7 +609,9 @@ module.exports = async (req: any, res: any, next: any) => {
// get parameters
days, mode, sort_by, order,
pendingSigs, centrality, nextYn,
numberOfRandomMembers, randomList,
numberOfRandomMembers: numberOfRandomMembers, randomList,
// Formulaire de recherche par UID ou PUB
uidOrPubList, uidOrPubValue,
// page data
currentBlockchainTimestamp,
......
......@@ -47,8 +47,10 @@ ${printMenu(MENU_LANG, help, "MEMBERS")}
<input type="checkbox" name="pendingSigs" value="yes" ${pendingSigs == 'yes' ? 'checked' : ''}>${LANG["CHECKBOX_PENDING_SIGS"]}.<br>
<input type="checkbox" name="mode" value="emitted" ${mode == 'emitted' ? 'checked' : ''}>${LANG["CHECKBOX_MODE_SIG"]}.<br>
<input type="checkbox" name="nextYn" value="yes" ${nextYn == 'yes' ? 'checked' : ''}> ${LANG["NEXT_YN"]}<br>
<input type="checkbox" name="randomList" value="yes" ${randomList == 'yes' ? 'checked' : ''}> ${LANG["RANDOM_LIST"]}
<input type="number" name="randomCounts" value="${numberOfRandomMembers}"/> ${LANG["MEMBERS"]}.<br>
<input type="checkbox" name="randomList" value="yes" ${randomList == 'yes' ? 'checked' : ''}> ${LANG["RANDOM_LIST"]}
<input type="number" name="randomCounts" value="${numberOfRandomMembers}"/> ${LANG["RANDOM_LIST_END"]}.<br>
<input type="checkbox" name="uidOrPubList" value="yes" ${uidOrPubList ? 'checked' : ''}> ${LANG["UID_OR_PUB_LIST"]}
<input type="search" name="uidOrPubValue" value="${uidOrPubValue || ''}"/> ${LANG["UID_OR_PUB_LIST_END"]}.<br>
<hr>
<!-- Afficher la légende et l'aide -->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment