Skip to content

Commit

Permalink
Fix filter and sorting not returning data properly
Browse files Browse the repository at this point in the history
  • Loading branch information
ruchernchong committed Oct 6, 2024
1 parent 171b54d commit 4ac69b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/v1/routes/coe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const buildSortQuery = (sort?: string, orderBy?: OrderBy): Sort => {
};

const buildMongoQuery = async <T>(query: QueryParams): Promise<Filter<T>> => {
const { from, to, month, ...filterQuery } = query;
const { sort, orderBy, from, to, ...filterQuery } = query;
const mongoQuery: Filter<T> = {};

if (from || to) {
Expand All @@ -43,7 +43,7 @@ const buildMongoQuery = async <T>(query: QueryParams): Promise<Filter<T>> => {
if (to && isValid(parse(to, "yyyy-MM", new Date()))) {
mongoQuery.month.$lte = to;
}
} else if (!month) {
} else if (!filterQuery.month) {
const latestMonth = parse(
await getLatestMonth(Collection.COE),
"yyyy-MM",
Expand Down

0 comments on commit 4ac69b4

Please sign in to comment.