improve WoT: daily decay and higher interaction divisor
This commit is contained in:
parent
46a2ac37eb
commit
9b3fa8d844
1
.gitignore
vendored
1
.gitignore
vendored
@ -18,6 +18,7 @@
|
|||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.pem
|
*.pem
|
||||||
|
db.sql
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
npm-debug.log*
|
npm-debug.log*
|
||||||
|
@ -148,7 +148,8 @@ async function getGraph (models) {
|
|||||||
from (
|
from (
|
||||||
select id, json_agg(json_build_object('node', oid, 'trust', trust)) as hops
|
select id, json_agg(json_build_object('node', oid, 'trust', trust)) as hops
|
||||||
from (
|
from (
|
||||||
select "ItemAct"."userId" as id, "Item"."userId" as oid, least(${MAX_TRUST}, count(*)/10.0) as trust
|
select "ItemAct"."userId" as id, "Item"."userId" as oid, least(${MAX_TRUST},
|
||||||
|
sum(POWER(.99, EXTRACT(DAY FROM (NOW_UTC() - "ItemAct".created_at))))/42.0) as trust
|
||||||
from "ItemAct"
|
from "ItemAct"
|
||||||
join "Item" on "itemId" = "Item".id and "ItemAct"."userId" <> "Item"."userId"
|
join "Item" on "itemId" = "Item".id and "ItemAct"."userId" <> "Item"."userId"
|
||||||
where "ItemAct".act = 'VOTE' group by "ItemAct"."userId", "Item"."userId"
|
where "ItemAct".act = 'VOTE' group by "ItemAct"."userId", "Item"."userId"
|
||||||
@ -167,11 +168,13 @@ async function storeTrust (models, nodeTrust) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the trust of each user in graph
|
// update the trust of each user in graph
|
||||||
await models.$executeRaw(
|
await models.$transaction([
|
||||||
|
models.$executeRaw`UPDATE users SET trust = 0`,
|
||||||
|
models.$executeRaw(
|
||||||
`UPDATE users
|
`UPDATE users
|
||||||
SET trust = g.trust
|
SET trust = g.trust
|
||||||
FROM (values ${values}) g(id, trust)
|
FROM (values ${values}) g(id, trust)
|
||||||
WHERE users.id = g.id`)
|
WHERE users.id = g.id`)])
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { trust }
|
module.exports = { trust }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user