@@ -6,48 +6,52 @@ import {
6
6
} from "../../utils/date-utils" ;
7
7
import { formatDistanceStrict , set } from "date-fns" ;
8
8
import { nb } from "date-fns/locale" ;
9
+ import { LeetStatus } from "./row-utils" ;
10
+ import { ScoredMessage } from "../score-engine" ;
9
11
10
- function formatLeetos ( rows : Awaited < ReturnType < typeof getTodaysLeets > > ) {
12
+ type StatusScoredMessageTuple = [ key : LeetStatus , rows : ScoredMessage [ ] ] ;
13
+
14
+ function formatLeetos ( rows : ScoredMessage [ ] ) {
11
15
return rows
12
16
. map ( ( row ) => {
13
- const { ms } = getTimeParts ( slackTsToDate ( row . ts ) ) ;
14
- return `:letopet: <@${ row . message . user } >: ${ ms } ms` ;
17
+ const { ms } = getTimeParts ( slackTsToDate ( row . message . ts ) ) ;
18
+ return `:letopet: <@${ row . message . message . user } >: ${ ms } ms (+ ${ row . points } ) ` ;
15
19
} )
16
20
. join ( "\n" ) ;
17
21
}
18
22
19
- function formatLeets ( rows : Awaited < ReturnType < typeof getTodaysLeets > > ) {
23
+ function formatLeets ( rows : ScoredMessage [ ] ) {
20
24
return rows
21
25
. map ( ( row ) => {
22
- const { seconds, ms } = getTimeParts ( slackTsToDate ( row . ts ) ) ;
23
- return `:letojam: <@${ row . message . user } >: ${ seconds } s ${ ms } ms` ;
26
+ const { seconds, ms } = getTimeParts ( slackTsToDate ( row . message . ts ) ) ;
27
+ return `:letojam: <@${ row . message . message . user } >: ${ seconds } s ${ ms } ms (+ ${ row . points } ) ` ;
24
28
} )
25
29
. join ( "\n" ) ;
26
30
}
27
31
28
- function formatPrematureRows ( rows : Awaited < ReturnType < typeof getTodaysLeets > > ) {
32
+ function formatPrematureRows ( rows : ScoredMessage [ ] ) {
29
33
return rows
30
34
. map ( ( row ) => {
31
- const { seconds, ms } = getTimeParts ( slackTsToDate ( row . ts ) ) ;
35
+ const { seconds, ms } = getTimeParts ( slackTsToDate ( row . message . ts ) ) ;
32
36
const negativeOffset = 1000 - ms ;
33
- return `:letogun: <@${ row . message . user } >: -${ negativeOffset } ms for tidlig :hot_face:` ;
37
+ return `:letogun: <@${ row . message . message . user } >: -${ negativeOffset } ms for tidlig :hot_face: ( ${ row . points } ) ` ;
34
38
} )
35
39
. join ( "\n" ) ;
36
40
}
37
41
38
- function formatLateRows ( rows : Awaited < ReturnType < typeof getTodaysLeets > > ) {
42
+ function formatLateRows ( rows : ScoredMessage [ ] ) {
39
43
return rows
40
44
. map ( ( row ) => {
41
- const date = slackTsToDate ( row . ts ) ;
45
+ const date = slackTsToDate ( row . message . ts ) ;
42
46
const { minutes, seconds } = getTimeParts ( date ) ;
43
47
return `:letoint: <@${
44
- row . message . user
45
- } >: ${ minutes } m ${ seconds } s (${ formatHours ( date ) } )`;
48
+ row . message . message . user
49
+ } >: ${ minutes } m ${ seconds } s (${ formatHours ( date ) } ) (+ ${ row . points } ) `;
46
50
} )
47
51
. join ( "\n" ) ;
48
52
}
49
53
50
- function messageFormatters ( rows : Awaited < ReturnType < typeof getTodaysLeets > > ) {
54
+ function messageFormatters ( rows : ScoredMessage [ ] ) {
51
55
return rows
52
56
. map ( ( row ) => {
53
57
const leet = set ( new Date ( ) , {
@@ -57,19 +61,19 @@ function messageFormatters(rows: Awaited<ReturnType<typeof getTodaysLeets>>) {
57
61
milliseconds : 0 ,
58
62
} ) ;
59
63
60
- const date = slackTsToDate ( row . ts ) ;
61
- return `:letoshake: <@${ row . message . user } >: ${ formatDistanceStrict (
64
+ const date = slackTsToDate ( row . message . ts ) ;
65
+ return `:letoshake: <@${ row . message . message . user } >: ${ formatDistanceStrict (
62
66
leet ,
63
67
date ,
64
68
{
65
69
locale : nb ,
66
70
} ,
67
- ) } bom :roflrofl: (${ formatHours ( date ) } )`;
71
+ ) } bom :roflrofl: (${ formatHours ( date ) } ) (+ ${ row . points } ) `;
68
72
} )
69
73
. join ( "\n" ) ;
70
74
}
71
75
72
- export function toCategoryMarkdown ( [ key , rows ] ) {
76
+ export function toCategoryMarkdown ( [ key , rows ] : StatusScoredMessageTuple ) {
73
77
switch ( key ) {
74
78
case "leetos" :
75
79
return `*Ekte leetos*:\n${ formatLeetos ( rows ) } ` ;
0 commit comments