mirror of
https://github.com/samsonjs/spirit-tracker.git
synced 2026-04-27 15:07:43 +00:00
feat: Randomized suggestions
This commit is contained in:
parent
130dbaf5d7
commit
c8fc3d9c7d
1 changed files with 11 additions and 4 deletions
|
|
@ -507,9 +507,11 @@ function computeInitialPairsFast(allAgg, mappedSkus, limitPairs, isIgnoredPairFn
|
||||||
if (out.length >= limitPairs) return out.slice(0, limitPairs);
|
if (out.length >= limitPairs) return out.slice(0, limitPairs);
|
||||||
|
|
||||||
// --- Existing logic continues (fills remaining slots), but avoid reusing SMWS-picked *unmapped* SKUs ---
|
// --- Existing logic continues (fills remaining slots), but avoid reusing SMWS-picked *unmapped* SKUs ---
|
||||||
const seeds = topSuggestions(work, Math.min(400, work.length), "", mappedSkus).filter(
|
const seedsPool = topSuggestions(work, Math.min(400, work.length), "", mappedSkus).filter(
|
||||||
(it) => !used.has(String(it?.sku || ""))
|
(it) => !used.has(String(it?.sku || ""))
|
||||||
);
|
);
|
||||||
|
shuffleInPlace(seedsPool, rnd);
|
||||||
|
const seeds = seedsPool.slice(0, Math.min(140, seedsPool.length));
|
||||||
|
|
||||||
const TOKEN_BUCKET_CAP = 500;
|
const TOKEN_BUCKET_CAP = 500;
|
||||||
const tokMap = new Map();
|
const tokMap = new Map();
|
||||||
|
|
@ -597,8 +599,13 @@ function computeInitialPairsFast(allAgg, mappedSkus, limitPairs, isIgnoredPairFn
|
||||||
const pairs = Array.from(bestByPair.values());
|
const pairs = Array.from(bestByPair.values());
|
||||||
pairs.sort((x, y) => y.score - x.score);
|
pairs.sort((x, y) => y.score - x.score);
|
||||||
|
|
||||||
for (const p of pairs) {
|
// Pick from a shuffled "top band" to keep quality but vary selection across reloads
|
||||||
const aSku = String(p.a.sku || "");
|
const TOP_BAND = 220;
|
||||||
|
const band = pairs.slice(0, Math.min(TOP_BAND, pairs.length));
|
||||||
|
shuffleInPlace(band, rnd);
|
||||||
|
|
||||||
|
for (const p of band) {
|
||||||
|
const aSku = String(p.a.sku || "");
|
||||||
const bSku = String(p.b.sku || "");
|
const bSku = String(p.b.sku || "");
|
||||||
if (!aSku || !bSku || aSku === bSku) continue;
|
if (!aSku || !bSku || aSku === bSku) continue;
|
||||||
if (used.has(aSku) || used.has(bSku)) continue;
|
if (used.has(aSku) || used.has(bSku)) continue;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue