Skip to content

Commit

Permalink
fix query
Browse files Browse the repository at this point in the history
  • Loading branch information
virgilchiriac committed Jan 24, 2025
1 parent c84df3b commit 2b16c4f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ export class DeletionExecutionConsole {
{
flags: '-l, --limit <value>',
/* istanbul ignore next */
fn: (value: string) => (value ? Number(value) : undefined),
fn: (value: string) => (value ? Number(value) : undefined), // NOSONAR
description: 'Limit of the requested deletion executions that should be performed.',
required: false,
},
{
flags: '-f, --runFailed <value>',
/* istanbul ignore next */
fn: (value: string) => /^(true|yes|1)$/i.test(value),
fn: (value: string) => /^(true|yes|1)$/i.test(value), // NOSONAR
description: 'Limit of the requested deletion executions that should be performed.',
required: false,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Scope } from '@shared/repo/scope';
import { FilterQuery } from '@mikro-orm/core';

Check failure on line 2 in apps/server/src/modules/deletion/repo/scope/deletion-request-scope.ts

View workflow job for this annotation

GitHub Actions / nest_lint

'FilterQuery' is defined but never used
import { DeletionRequestEntity } from '../entity';
import { StatusModel } from '../../domain/types';

Expand All @@ -10,18 +11,22 @@ export class DeletionRequestScope extends Scope<DeletionRequestEntity> {
}

byStatusAndDate(status: StatusModel[], olderThan?: Date, newerThan?: Date): this {
let query = { status: { $in: status } };
const query: any[] = [];

const statusQuery = { status: { $in: status } };
query.push(statusQuery);

if (olderThan) {
const olderThanQuery = { updatedAt: { $lt: olderThan } };
query = { ...query, ...olderThanQuery };
query.push(olderThanQuery);
}

if (newerThan) {
const newerThanQuery = { updatedAt: { $gte: newerThan } };
query = { ...query, ...newerThanQuery };
query.push(newerThanQuery);
}

this.addQuery(query);
this.addQuery({ ...query });

return this;
}
Expand Down

0 comments on commit 2b16c4f

Please sign in to comment.