credGrainViewCredTable = (credGrainView, minCred = 0, weeksLookBack = 0) => {
let cgv = credGrainView;
const two = cgv
.withTimeScopeFromLookback(Date.now(), 2)
.participants()
.slice()
.sort((a, b) => b.cred - a.cred);
const four = cgv
.withTimeScopeFromLookback(Date.now(), 4)
.participants()
.slice()
.sort((a, b) => b.cred - a.cred);
if (weeksLookBack)
cgv = cgv.withTimeScopeFromLookback(Date.now(), weeksLookBack);
const table = cgv
.participants()
.slice()
.filter((p) => p.cred > minCred)
.sort((a, b) => b.cred - a.cred)
.map(
(p, index) =>
`|${p.identity.name}` +
`|${p.cred.toFixed(0)}` +
`|` +
`|${two[index].identity.name}` +
`|${two[index].cred.toFixed(0)}` +
`|` +
`|${four[index].identity.name}` +
`|${four[index].cred.toFixed(0)}|`
);
return md`|Total|Cred|-|Last 2 weeks||-| Last 4 weeks ||\n|---|---|---|---|---|---|---|\n${table.join(
"\n"
)}`;
}