Better, non-hacky solution

This commit is contained in:
Matt Godbolt
2025-01-09 17:17:47 -06:00
parent 23262b5227
commit 4c8ccca59b
+3 -7
View File
@@ -107,13 +107,9 @@ export function makeIconSets(
const toPick = icons.map(icon => {
return {
icon: icon,
// Number of times we'd expect to see this, divided by number of times we saw it. Special cased for
// icons that have to show every time. Which kinda tells me the algorithm is broken, but this was
// enough to get things working for now.
error:
icon.topIconShowEvery === 1
? Infinity
: result.length / icon.topIconShowEvery / (sponsorAppearanceCount.get(icon) || 0.00001),
// Number of times we'd expect to see this, divided by number of times we saw it, assuming that we pick
// this one next.
error: (result.length + 1) / icon.topIconShowEvery / ((sponsorAppearanceCount.get(icon) || 0) + 1),
};
});
toPick.sort((lhs, rhs) => rhs.error - lhs.error);