diff --git a/src/api/comm.libraryofcode.org/routes/report.ts b/src/api/comm.libraryofcode.org/routes/report.ts index 216a334..d1db65a 100644 --- a/src/api/comm.libraryofcode.org/routes/report.ts +++ b/src/api/comm.libraryofcode.org/routes/report.ts @@ -110,6 +110,36 @@ export default class Report extends Route { const array: ScoreHistoricalRaw[] = []; for (const data of historicalData) { delete data.report?.softInquiries; + + let total: number; + let activity: number; + const moderation = Math.round(data.report.moderation); + let role: number; + let cloud: number; + const other = Math.round(data.report.other); + let misc: number; + + if (data.report.total < 200) total = 0; + else if (data.report.total > 800) total = 800; + else total = Math.round(data.report.total); + + if (member.activity < 10) activity = 0; + else if (data.report.activity > Math.floor((Math.log1p(3000 + 300 + 200 + 100) * 12))) activity = Math.floor((Math.log1p(3000 + 300 + 200 + 100) * 12)); + else activity = Math.round(data.report.activity); + + if (data.report.roles <= 0) role = 0; + else if (data.report.roles > 54) role = 54; + else activity = Math.round(data.report.roles); + + if (data.report.staff <= 0) role = 0; + else activity = Math.round(data.report.staff); + + if (data.report.cloudServices === 0) cloud = 0; + else if (data.report.cloudServices > 10) cloud = 10; + else cloud = Math.round(data.report.cloudServices); + + data.report.total = total; data.report.activity = activity; data.report.moderation = moderation; data.report.roles = role; data.report.cloudServices = cloud; data.report.other = other; data.report.staff = misc; + array.push(data); }