fix(ui): учитывать весь каталог Community в оптимизаторе
This commit is contained in:
1 parent
53603f17c1
commit
991f2b3871
9 files changed
+100
-12
No files matched your search
@@ -542,7 +542,7 @@ export function buildLiveOptimizerData(
|
||||
sorted.sort((a, b) => b.probabilityOptimal - a.probabilityOptimal)
|
||||
const best = sorted[0] ?? null
|
||||
|
||||
const commRecs: CommRec[] = flatRules.filter(rule=>rule.sourceServerId===home.id).slice(0, 24).map((rule) => {
|
||||
const commRecs: CommRec[] = flatRules.filter(rule=>rule.sourceServerId===home.id).map((rule) => {
|
||||
const curProb = 38 + (rule.community.length % 12)
|
||||
const recProb = best ? Math.min(92, curProb + 18 + (best.score % 10)) : curProb
|
||||
const rec = best
|
||||
|
||||
@@ -40,3 +40,13 @@ test("Community recommendations belong to their source home only",()=>{
|
||||
assert.deepEqual(result.homes[0].commRecs.map(r=>r.community),["65001:1"])
|
||||
assert.deepEqual(result.homes[1].commRecs.map(r=>r.community),["65001:4"])
|
||||
})
|
||||
|
||||
|
||||
test("Community catalog retains all 1000 source rules without inventing indices",()=>{
|
||||
const inventory=rows.filter(row=>row.type!=="exit-node")
|
||||
const rules=Array.from({length:1000},(_,i)=>({id:String(i+1),community:'65001:'+String(i+1),communityName:'Service '+(i+1),gateway:'192.0.2.2',gatewayTunnelId:'',description:''}))
|
||||
const result=buildLiveOptimizerData(inventory,[{serverId:'1',rules}],DEFAULT_ROUTE_AI_OPTIMIZER_SETTINGS)
|
||||
const recs=result.homes[0].commRecs
|
||||
assert.equal(recs.length,1000);assert.equal(recs[999].community,'65001:1000')
|
||||
assert.ok(recs.every(rec=>rec.current===null&&rec.recommended===null&&!rec.shouldSwitch))
|
||||
})
|
||||
Reference in new issue
Block a user