@@ -13,19 +13,9 @@ import { ResponseDto } from 'src/dto/api-response.dto';
1313import { PaymentStatus } from 'src/dto/payment.dto' ;
1414import { WinningAuditDto , AuditPayoutDto } from './dto/audit.dto' ;
1515import { WinningUpdateRequestDto } from './dto/winnings.dto' ;
16- import { TopcoderChallengesService } from 'src/shared/topcoder/challenges.service' ;
17- import { Logger , getBaClient } from 'src/shared/global' ;
16+ import { Logger } from 'src/shared/global' ;
1817import { WinningRequestDto } from 'src/dto/winning.dto' ;
19-
20- function formatDate ( date = new Date ( ) ) {
21- const pad = ( n , z = 2 ) => String ( n ) . padStart ( z , '0' ) ;
22-
23- return (
24- `${ date . getFullYear ( ) } -${ pad ( date . getMonth ( ) + 1 ) } -${ pad ( date . getDate ( ) ) } ` +
25- `${ pad ( date . getHours ( ) ) } :${ pad ( date . getMinutes ( ) ) } :${ pad ( date . getSeconds ( ) ) } .` +
26- `${ pad ( date . getMilliseconds ( ) , 3 ) } `
27- ) ;
28- }
18+ import { BillingAccountsService } from 'src/shared/topcoder/billing-accounts.service' ;
2919
3020/**
3121 * The admin winning service.
@@ -41,20 +31,9 @@ export class AdminService {
4131 constructor (
4232 private readonly prisma : PrismaService ,
4333 private readonly paymentsService : PaymentsService ,
44- private readonly tcChallengesService : TopcoderChallengesService ,
34+ private readonly baService : BillingAccountsService ,
4535 ) { }
4636
47- async getBillingAccountsForUser ( userId : string ) : Promise < string [ ] > {
48- const baPrisma = getBaClient ( ) ;
49- const baRows = await baPrisma . billingAccountAccess . findMany ( {
50- where : {
51- userId,
52- }
53- } ) ;
54-
55- return baRows . map ( r => `${ r . billingAccountId } ` ) ;
56- }
57-
5837 async applyBaAdminUserFilters (
5938 userId : string ,
6039 isBaAdmin ?: boolean ,
@@ -66,7 +45,7 @@ export class AdminService {
6645
6746 return {
6847 ...filters ,
69- billingAccounts : await this . getBillingAccountsForUser ( userId ) ,
48+ billingAccounts : await this . baService . getBillingAccountsForUser ( userId ) ,
7049 } ;
7150 }
7251
@@ -109,15 +88,15 @@ export class AdminService {
10988 } ,
11089 select : {
11190 billing_account : true ,
112- }
113- } ) ; ;
91+ } ,
92+ } ) ;
11493
11594 if ( ! payments || payments . length === 0 ) {
11695 // nothing to check
11796 return ;
11897 }
11998
120- const allowedBAs = await this . getBillingAccountsForUser ( userId ) ;
99+ const allowedBAs = await this . baService . getBillingAccountsForUser ( userId ) ;
121100 const paymentBAs = payments
122101 . map ( ( p ) => p . billing_account )
123102 . filter ( ( b ) => b !== null && b !== undefined ) ;
@@ -173,8 +152,6 @@ export class AdminService {
173152 throw new NotFoundException ( 'failed to get current payments' ) ;
174153 }
175154
176-
177-
178155 let releaseDate ;
179156 if ( body . paymentStatus ) {
180157 releaseDate = await this . getPaymentReleaseDateByWinningsId ( winningsId ) ;
0 commit comments