-
Notifications
You must be signed in to change notification settings - Fork 0
/
output.ts
31 lines (29 loc) 路 1022 Bytes
/
output.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { GetReportOptions, Report } from "./geekbot.ts";
import { SECOND } from "https://deno.land/std@0.100.0/datetime/mod.ts";
export function renderResults(
reports: Report[],
{ standup, user, question, after, before }: GetReportOptions,
) {
const headerText =
`${standup.channel} > ${user.username} > '${question.text}'`.toUpperCase();
const headerSubtitle = (after || before)
? `\n${after ? `from ${after.toLocaleDateString()} ` : ""}until ${
before ? before.toLocaleDateString() : "now"
}`
: "";
const headerDivider = "\n" + "=".repeat(headerText.length);
console.log(
`%c${headerText}${headerSubtitle}${headerDivider}`,
"color:palegreen;font-weight:bold",
);
reports.forEach((r) => {
if (r.questions.length > 0) {
console.group(
`%c${new Date(r.timestamp * SECOND).toLocaleString()}`,
"color:yellowgreen;font-weight:bold",
);
console.log(r.questions.map(({ answer }) => answer).join(""));
console.groupEnd();
}
});
}