Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 12ac856

Browse files
authored
Merge pull request #72 from skenaja/bugfix/featured-fix
Featured feed: Fix issue with tzkt scores and improve rate limiting
2 parents 351f7f6 + 5aab6f5 commit 12ac856

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/conseil.js

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ const ONE_HOUR_MILLIS = 60 * ONE_MINUTE_MILLIS
2222
const ONE_DAY_MILLIS = 24 * ONE_HOUR_MILLIS
2323
const ONE_WEEK_MILLIS = 7 * ONE_DAY_MILLIS
2424

25-
Map.prototype.mapMap = function(callback) {
26-
const output = new Map()
27-
this.forEach((element, key)=>{
28-
output.set(key, callback(element, key))
29-
})
30-
return output
31-
}
32-
3325
Array.prototype.sum = Array.prototype.sum || function (){
3426
return this.reduce(function(p,c){return p+c},0);
3527
};
@@ -1114,7 +1106,7 @@ const getFeaturedArtisticUniverse = async (max_time) => {
11141106
let minters = _.take(_.uniq(minter_arr), 30)
11151107
const limiter = new Bottleneck({
11161108
maxConcurrent: 1,
1117-
minTime: 2
1109+
minTime: 20
11181110
});
11191111
let tzktscores = new Map()
11201112
let scoreTask = Promise.all(
@@ -1172,11 +1164,13 @@ const getFeaturedArtisticUniverse = async (max_time) => {
11721164

11731165

11741166
let replacementScore = Object.values(tzktscores).filter(v => v !== -1).avg() / 2
1175-
tzktscores = tzktscores.mapMap((value, key) => {
1167+
tzktscores = _.mapValues(tzktscores, function(value) {
11761168
if (value === -1) {
11771169
return replacementScore
1170+
} else
1171+
{
1172+
return value
11781173
}
1179-
return value
11801174
})
11811175
// Cost to be on feed per objekt last 7 days shouldn't be higher than any of:
11821176
// 0.5tez

0 commit comments

Comments
 (0)