Skip to content

Commit

Permalink
fix for pg search (#798)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakprabhakara committed Mar 20, 2023
1 parent d4c2a74 commit a26275c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/handlers/graphql/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ export default async function search(q: any, args: Args, context: Scope) {
edges,
pageInfo: {
hasNextPage: opts.sort === "asc" && totalCount > results.events.length,
hasPreviousPage:
opts.sort === "desc" && totalCount > results.events.length,
hasPreviousPage: opts.sort === "desc" && totalCount > results.events.length,
},
};
}
Expand Down
6 changes: 2 additions & 4 deletions src/models/event/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ export default async function filter(opts: Options): Promise<Result> {
SELECT doc
FROM indexed_events
WHERE ${wheres.join(" AND ")}
ORDER BY (doc-> 'canonical_time')::text::bigint ${_.toUpper(
opts.sort
)}, id ${_.toUpper(opts.sort)}
ORDER BY (doc-> 'canonical_time')::text::bigint ${_.toUpper(opts.sort)}, id ${_.toUpper(opts.sort)}
LIMIT ${size}`;

const results = await pgPool.query(q, vals);
Expand All @@ -73,7 +71,7 @@ export default async function filter(opts: Options): Promise<Result> {

return {
events,
totalHits,
totalHits: { value: totalHits },
};
}

Expand Down

0 comments on commit a26275c

Please sign in to comment.