Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
nodes
typescript
modules
duniter-currency-monit
Commits
62787b09
Commit
62787b09
authored
Apr 05, 2020
by
Cédric Moreau
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[refact] abstracted `gaussianWotQuality`
parent
415770b0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
8 deletions
+12
-8
routes/gaussianWotQuality2.ts
routes/gaussianWotQuality2.ts
+11
-7
routes/index.js
routes/index.js
+1
-1
No files found.
routes/gaussianWotQuality
.j
s
→
routes/gaussianWotQuality
2.t
s
View file @
62787b09
"
use strict
"
;
import
{
DataFinder
}
from
"
../lib/DataFinder
"
;
const
co
=
require
(
'
co
'
)
const
constants
=
require
(
__dirname
+
'
/../lib/constants
'
)
...
...
@@ -9,9 +11,11 @@ const getLang = require(__dirname + '/../lib/getLang')
// gaussianWotQuality cache
var
previousNextYn
=
"
no
"
;
module
.
exports
=
(
req
,
res
,
next
)
=>
co
(
function
*
()
{
module
.
exports
=
async
(
req
:
any
,
res
:
any
,
next
:
any
)
=>
{
var
{
duniterServer
}
=
req
.
app
.
locals
const
dataFinder
=
new
DataFinder
(
duniterServer
)
try
{
// get GET parameters
...
...
@@ -37,7 +41,7 @@ module.exports = (req, res, next) => co(function *() {
let
tabLimit1
=
[];
// Récupérer la liste des identités ayant actuellement le statut de membre
let
membersList
=
yield
duniterServer
.
dal
.
peerDAL
.
query
(
'
SELECT `uid`,`wotb_id` FROM i_index WHERE `m
ember
`=1
'
);
let
membersList
=
await
dataFinder
.
getM
ember
s
(
);
// 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
))
...
...
@@ -63,7 +67,7 @@ module.exports = (req, res, next) => co(function *() {
switch
(
unit
)
{
case
'
percentReached
'
:
limit1
=
conf
.
xpercent
*
100
;
label
=
LANG
[
'
PERCENT_REACHED
'
];
break
;
case
'
nbReached
'
:
limit1
=
parseInt
(
conf
.
xpercent
*
nbSentries
);
label
=
LANG
[
'
NB_REACHED
'
];
break
;
case
'
nbReached
'
:
limit1
=
parseInt
(
String
(
conf
.
xpercent
*
nbSentries
)
)
;
label
=
LANG
[
'
NB_REACHED
'
];
break
;
default
:
break
;
}
...
...
@@ -112,10 +116,10 @@ module.exports = (req, res, next) => co(function *() {
}
// Remplir les tableaux triée de façon gaussienne
let
idGaussian
=
parseInt
(
i
/
2
)
;
let
idGaussian
=
i
/
2
;
if
(
!
debut
)
{
idGaussian
=
parseInt
(
tabMembersQuality
.
length
-
(
i
/
2
)
)
;
idGaussian
=
tabMembersQuality
.
length
-
(
i
/
2
);
}
debut
=
!
debut
;
tabMembersQualitySorted
[
idGaussian
]
=
tabMembersQuality
[
idMin
];
...
...
@@ -162,7 +166,7 @@ module.exports = (req, res, next) => co(function *() {
else
{
unitCoeff
*=
100.0
;
}
for
(
let
i
=
0
;
i
<
tabMembersQualitySorted
.
length
;
i
++
)
{
tabMembersQualitySorted
[
i
]
=
parseInt
(
tabMembersQualitySorted
[
i
]
*
unitCoeff
)
;
tabMembersQualitySorted
[
i
]
=
tabMembersQualitySorted
[
i
]
*
unitCoeff
;
}
}
...
...
@@ -238,4 +242,4 @@ module.exports = (req, res, next) => co(function *() {
// En cas d'exception, afficher le message
res
.
status
(
500
).
send
(
`<pre>
${
e
.
stack
||
e
.
message
}
</pre>`
);
}
})
\ No newline at end of file
}
routes/index.js
View file @
62787b09
...
...
@@ -121,7 +121,7 @@ app.get('/wotex',
* Graphe gaussien de la qualité des membres
********************************************/
app
.
get
(
'
/gaussianWotQuality
'
,
require
(
__dirname
+
'
/gaussianWotQuality.js
'
),
require
(
__dirname
+
'
/gaussianWotQuality
2
.js
'
),
(
req
,
res
)
=>
res
.
render
(
'
Chart.html
'
,
{
printMenu
,
pageName
:
'
GAUSSIAN_WOT_QUALITY
'
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment