Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
duniter-currency-monit
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
nodes
typescript
modules
duniter-currency-monit
Commits
0863718a
Commit
0863718a
authored
5 years ago
by
Cédric Moreau
Browse files
Options
Downloads
Patches
Plain Diff
[refact] migrate `gaussianWotQuality` module
parent
cc64d9f7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/DataFinder.ts
+24
-5
24 additions, 5 deletions
lib/DataFinder.ts
with
24 additions
and
5 deletions
lib/DataFinder.ts
+
24
−
5
View file @
0863718a
...
...
@@ -2,7 +2,7 @@ import {Server} from 'duniter/server'
import
{
DBBlock
}
from
'
duniter/app/lib/db/DBBlock
'
import
{
MonitorExecutionTime
}
from
'
./MonitorExecutionTime
'
import
{
LevelDBIindex
}
from
"
duniter/app/lib/dal/indexDAL/leveldb/LevelDBIindex
"
;
import
{
reduce
}
from
"
duniter/app/lib/indexer
"
;
import
{
IindexEntry
,
reduce
}
from
"
duniter/app/lib/indexer
"
;
export
class
DataFinder
{
...
...
@@ -13,6 +13,7 @@ export class DataFinder {
}
=
{};
// Cache
private
intemporalWot
:
Promise
<
IindexEntry
[]
>
;
private
wotmap
:
Promise
<
WotMap
>
;
constructor
(
protected
duniterServer
:
Server
)
{
...
...
@@ -97,7 +98,10 @@ export class DataFinder {
@
MonitorExecutionTime
()
getMembers
()
{
return
this
.
getFromCacheOrDB
(
'
getMembers
'
,
'
members
'
,
()
=>
this
.
query
(
'
SELECT `uid`,`pub`,`member`,`written_on`,`wotb_id` FROM i_index WHERE `member`=1
'
))
return
this
.
getFromCacheOrDB
(
'
getMembers
'
,
'
members
'
,
async
()
=>
{
const
intemporalWot
=
await
this
.
getIntemporalWot
();
return
intemporalWot
.
filter
(
node
=>
node
.
member
)
})
}
@
MonitorExecutionTime
()
...
...
@@ -196,6 +200,16 @@ export class DataFinder {
return
this
.
duniterServer
.
dal
.
iindexDAL
as
LevelDBIindex
}
/**
* Singleton de fetching de la wotmap
*/
getIntemporalWot
()
{
if
(
!
this
.
intemporalWot
)
{
this
.
intemporalWot
=
this
.
fetchIntemporalWot
()
}
return
this
.
intemporalWot
}
/**
* Singleton de fetching de la wotmap
*/
...
...
@@ -206,9 +220,14 @@ export class DataFinder {
return
this
.
wotmap
}
async
fetchIntemporalWot
()
{
console
.
log
(
'
Fetching intemporal wot...
'
);
return
(
await
this
.
iindex
.
findAllValues
()).
map
(
reduce
);
}
async
fetchWotMap
()
{
console
.
log
(
'
Fetching wotmap...
'
)
const
reducedIdentities
=
(
await
this
.
iindex
.
findAllValues
()).
map
(
reduce
);
console
.
log
(
'
Fetching wotmap...
'
)
;
const
reducedIdentities
=
await
this
.
getIntemporalWot
(
);
const
wotmap
:
WotMap
=
{};
reducedIdentities
.
forEach
(
identity
=>
{
wotmap
[
identity
.
wotb_id
as
number
]
=
identity
;
...
...
@@ -218,5 +237,5 @@ export class DataFinder {
}
interface
WotMap
{
[
k
:
number
]:
an
y
[
k
:
number
]:
IindexEntr
y
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment