@@ -55,23 +55,23 @@ export class ReportsService {
5555 this . tableName = this . configService . get < string > ( 'dynamodbReportsTable' ) ! ;
5656 }
5757
58- async findAll ( userId : string , withFailed = false ) : Promise < Report [ ] > {
58+ async findAll ( userId : string , onlyProcessed = true ) : Promise < Report [ ] > {
5959 if ( ! userId ) {
6060 throw new ForbiddenException ( 'User ID is required' ) ;
6161 }
6262
6363 try {
6464 const expressionAttributeValues : any = { ':userId' : userId } ;
65- const processingStatusFilter = 'processingStatus <> :failedStatus ' ;
65+ const processingStatusFilter = 'processingStatus = :processedStatus ' ;
6666
67- if ( ! withFailed ) {
68- expressionAttributeValues [ ':failedStatus ' ] = ProcessingStatus . FAILED ;
67+ if ( onlyProcessed ) {
68+ expressionAttributeValues [ ':processedStatus ' ] = ProcessingStatus . PROCESSED ;
6969 }
7070
7171 const command = new QueryCommand ( {
7272 TableName : this . tableName ,
7373 KeyConditionExpression : 'userId = :userId' ,
74- FilterExpression : ! withFailed ? processingStatusFilter : undefined ,
74+ FilterExpression : onlyProcessed ? processingStatusFilter : undefined ,
7575 ExpressionAttributeValues : marshall ( expressionAttributeValues ) ,
7676 } ) ;
7777
@@ -100,7 +100,7 @@ export class ReportsService {
100100 async findLatest (
101101 queryDto : GetReportsQueryDto ,
102102 userId : string ,
103- withFailed = false ,
103+ onlyProcessed = true ,
104104 ) : Promise < Report [ ] > {
105105 this . logger . log (
106106 `Running findLatest with params: ${ JSON . stringify ( queryDto ) } for user ${ userId } ` ,
@@ -116,17 +116,17 @@ export class ReportsService {
116116 const expressionAttributeValues : any = { ':userId' : userId } ;
117117
118118 try {
119- const processingStatusFilter = 'processingStatus <> :failedStatus ' ;
119+ const processingStatusFilter = 'processingStatus = :processedStatus ' ;
120120
121- if ( ! withFailed ) {
122- expressionAttributeValues [ ':failedStatus ' ] = ProcessingStatus . FAILED ;
121+ if ( onlyProcessed ) {
122+ expressionAttributeValues [ ':processedStatus ' ] = ProcessingStatus . PROCESSED ;
123123 }
124124
125125 const command = new QueryCommand ( {
126126 TableName : this . tableName ,
127127 IndexName : 'userIdCreatedAtIndex' ,
128128 KeyConditionExpression : 'userId = :userId' ,
129- FilterExpression : ! withFailed ? processingStatusFilter : undefined ,
129+ FilterExpression : onlyProcessed ? processingStatusFilter : undefined ,
130130 ExpressionAttributeValues : marshall ( expressionAttributeValues ) ,
131131 ScanIndexForward : false ,
132132 Limit : limit ,
0 commit comments