Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add price nulls to tokenEntityList resolver #285

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/server-extension/model/tokenEntity.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export enum OrderBy {
createdAt_DESC = "createdAt_DESC",
price_ASC = "price_ASC",
price_DESC = "price_DESC",

price_ASC_NULLS_FIRST = "price_ASC_NULLS_FIRST",
price_ASC_NULLS_LAST = "price_ASC_NULLS_LAST",
price_DESC_NULLS_FIRST = "price_DESC_NULLS_FIRST",
price_DESC_NULLS_LAST = "price_DESC_NULLS_LAST",
}

registerEnumType(OrderBy, {
Expand Down Expand Up @@ -167,4 +170,3 @@ export class TokenEntityQueryResult {
Object.assign(this, props);
}
}

6 changes: 5 additions & 1 deletion src/server-extension/resolvers/tokenEntities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ ORDER BY ${orderQuery} LIMIT $2 OFFSET $3;
[OrderBy.updatedAt_DESC]: 'updated_at DESC',
[OrderBy.price_ASC]: 'cheapest_price ASC',
[OrderBy.price_DESC]: 'cheapest_price DESC',
}
[OrderBy.price_ASC_NULLS_FIRST]: 'cheapest_price ASC NULLS FIRST',
[OrderBy.price_ASC_NULLS_LAST]: 'cheapest_price ASC NULLS LAST',
[OrderBy.price_DESC_NULLS_FIRST]: 'cheapest_price DESC NULLS FIRST',
[OrderBy.price_DESC_NULLS_LAST]: 'cheapest_price DESC NULLS LAST',
};

private getOrderByQuery(orderBy: string[] = [OrderBy.blockNumber_DESC]): string {
return orderBy.map((order) => this.ORDER_BY_MAPPING[order]).join(', ')
Expand Down