Skip to content

Commit

Permalink
fix(filter): use passed timestamp column name
Browse files Browse the repository at this point in the history
  • Loading branch information
kostyazgara committed May 26, 2023
1 parent 1c7ad34 commit afa403f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions packages/filter/lib/interceptors/filter-timestamp.interceptor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class FilterTimestampInterceptor<TRecord, TResult>
const timestampFilter = options[this.timestampField as string];
if (this.isNumber(timestampFilter)) {
queryBuilder.where(
addPrefixColumn('created_at', options.alias),
addPrefixColumn(this.timestampField as string, options.alias),
timestampFilter,
);
} else {
Expand Down Expand Up @@ -63,15 +63,18 @@ export class FilterTimestampInterceptor<TRecord, TResult>
value: number,
alias?: string,
): void {
const createdAtColumnName = addPrefixColumn('created_at', alias);
const timestampColumnName = addPrefixColumn(
this.timestampField as string,
alias,
);
if (operator === 'gt') {
queryBuilder.where(createdAtColumnName, '>', value);
queryBuilder.where(timestampColumnName, '>', value);
} else if (operator === 'gte') {
queryBuilder.where(createdAtColumnName, '>=', value);
queryBuilder.where(timestampColumnName, '>=', value);
} else if (operator === 'lt') {
queryBuilder.where(createdAtColumnName, '<', value);
queryBuilder.where(timestampColumnName, '<', value);
} else if (operator === 'lte') {
queryBuilder.where(createdAtColumnName, '<=', value);
queryBuilder.where(timestampColumnName, '<=', value);
}
}
}

0 comments on commit afa403f

Please sign in to comment.