fedimbed: format poll option counts

This commit is contained in:
Cynthia Foxwell 2025-04-17 22:00:37 -06:00
parent 55553ada6a
commit 66aa9cc1c7
Signed by: Cynosphere
SSH key fingerprint: SHA256:H3SM8ufP/uxqLwKSH7xY89TDnbR9uOHzjLoBr0tlajk

View file

@ -103,6 +103,7 @@ const statsFormatter = Intl.NumberFormat("en-US", {
notation: "compact",
maximumFractionDigits: 1,
});
const numberFormatter = Intl.NumberFormat("en-US");
const domainCache = new Map();
domainCache.set("cohost.org", "cohost"); // no nodeinfo
@ -1516,9 +1517,9 @@ async function processUrl(msg, url, spoiler = false, command = false) {
const percent = o.count / poll.total;
const bar = Math.round(percent * 32);
return `**${o.name}** (${o.count}, ${Math.round(percent * 100)}%)\n\`${"\u2588".repeat(bar)}${" ".repeat(
32 - bar
)}\``;
return `**${o.name}** (${numberFormatter.format(o.count)}, ${Math.round(
percent * 100
)}%)\n\`${"\u2588".repeat(bar)}${" ".repeat(32 - bar)}\``;
})
.join("\n\n") + `\n\n${poll.total} votes \u2022 Ends <t:${Math.floor(poll.end.getTime() / 1000)}:R>`,
});