@@ -20,20 +20,20 @@ import type {
20
20
} from "~dm-types/events/EdgeCreationEvent" ;
21
21
import type { MedalEvent } from "~dm-types/events/MedalEvent" ;
22
22
import type { SignupEvent } from "~dm-types/events/SignupEvent" ;
23
+ import MEDAL_LEVELS from "~dm-types/MedalLevels" ;
23
24
import { prismaClient as prismaDm } from "~prisma-schemas/schemas/dm/client" ;
24
25
25
26
import namespaces from "../namespaces" ;
26
- import MEDAL_LEVELS from "~dm-types/MedalLevels" ;
27
27
28
28
const listenEvents = ( ) => ( {
29
29
getEvents : ( ) =>
30
30
Promise . all ( [
31
- retrieveSignups ( ) ,
32
- retrieveCollectionUpdates ( ) ,
33
- retrieveCollectionSubscriptionAdditions ( ) ,
34
- retrieveBookstoreCreations ( ) ,
35
- retrieveEdgeCreations ( ) ,
36
- retrieveNewMedals ( ) ,
31
+ retrieveSignups ( ) ,
32
+ retrieveCollectionUpdates ( ) ,
33
+ retrieveCollectionSubscriptionAdditions ( ) ,
34
+ retrieveBookstoreCreations ( ) ,
35
+ retrieveEdgeCreations ( ) ,
36
+ retrieveNewMedals ( ) ,
37
37
] ) . then ( ( data ) => data . flat ( ) ) ,
38
38
} ) ;
39
39
@@ -161,36 +161,36 @@ const retrieveNewMedals = async () =>
161
161
(
162
162
(
163
163
await prismaDm . userContribution . findMany ( {
164
- select : {
165
- totalPoints : true ,
166
- newPoints : true ,
167
- userId : true ,
168
- contribution : true ,
169
- date : true ,
170
- } ,
171
- where : {
172
- date : {
173
- gt : dayjs ( ) . subtract ( 1 , "month" ) . toDate ( ) ,
164
+ select : {
165
+ totalPoints : true ,
166
+ newPoints : true ,
167
+ userId : true ,
168
+ contribution : true ,
169
+ date : true ,
170
+ } ,
171
+ where : {
172
+ date : {
173
+ gt : dayjs ( ) . subtract ( 1 , "month" ) . toDate ( ) ,
174
+ } ,
174
175
} ,
175
- } ,
176
176
} )
177
- )
177
+ )
178
178
. map ( ( { contribution, newPoints, totalPoints, userId, date } ) => ( {
179
- contribution : Object . keys ( MEDALS_L10N_FR ) . find (
179
+ contribution : Object . keys ( MEDALS_L10N_FR ) . find (
180
180
( medalType ) => MEDALS_L10N_FR [ medalType ] === contribution ,
181
- ) ,
182
- userId,
183
- timestamp : dayjs ( date ) . subtract ( 2 , "hour" ) . unix ( ) ,
184
- type : "medal" ,
181
+ ) ,
182
+ userId,
183
+ timestamp : dayjs ( date ) . subtract ( 2 , "hour" ) . unix ( ) ,
184
+ type : "medal" ,
185
185
level :
186
186
Object . entries (
187
- Object . entries ( MEDAL_LEVELS ) . find (
187
+ Object . entries ( MEDAL_LEVELS ) . find (
188
188
( [ medalType ] ) => contribution === MEDALS_L10N_FR [ medalType ] ,
189
189
) ! [ 1 ] ,
190
- ) . find (
190
+ ) . find (
191
191
( [ , points ] ) =>
192
192
totalPoints >= points && totalPoints - newPoints < points ,
193
- ) ?. [ 0 ] || null ,
193
+ ) ?. [ 0 ] || null ,
194
194
} ) )
195
- . filter ( ( { level } ) => level !== null ) as AbstractEventRaw [ ]
196
- ) . map ( mapUsers < MedalEvent > ) ;
195
+ . filter ( ( { level } ) => level !== null ) as AbstractEventRaw [ ]
196
+ ) . map ( mapUsers < MedalEvent > ) ;
0 commit comments