Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(attributes->>'validatorVoteBalance')::numeric AS vote_balance,
COALESCE((attributes->>'validatorResigned')::boolean, FALSE) AS is_resigned
FROM wallets
WHERE attributes ? 'validatorPublicKey'
WHERE attributes ? 'validatorPublicKey' AND attributes->>'validatorPublicKey' <> ''

Check warning on line 16 in packages/api-database/source/migrations/1729064427168-CreateUpdateValidatorRankingFunction.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-database/source/migrations/1729064427168-CreateUpdateValidatorRankingFunction.ts#L16

Added line #L16 was not covered by tests
),
ranking AS (
SELECT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
{
expressions: [
{ attribute: "validatorPublicKey", op: "jsonbAttributeExists", property: "attributes" },
{
jsonFieldAccessor: { fieldName: "validatorPublicKey", operator: "->>" },
op: "notEqual",
property: "attributes",
value: "",
},

Check warning on line 31 in packages/api-database/source/search/filters/validator-filter.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-database/source/search/filters/validator-filter.ts#L26-L31

Added lines #L26 - L31 were not covered by tests
],
op: "and",
},
Expand Down
7 changes: 7 additions & 0 deletions packages/api-database/source/search/query-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@
const parameters = { [parameter]: expression.value };
return { parameters, query };
}
case "notEqual": {
const column = this.getColumnName(metadata, expression.property, expression.jsonFieldAccessor);
const parameter = `p${this.paramNo++}`;
const query = `${column} <> :${parameter}`;
const parameters = { [parameter]: expression.value };
return { parameters, query };
}

Check warning on line 84 in packages/api-database/source/search/query-helper.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-database/source/search/query-helper.ts#L78-L84

Added lines #L78 - L84 were not covered by tests
case "between": {
const column = this.getColumnName(metadata, expression.property, expression.jsonFieldAccessor);
const parameterFrom = `p${this.paramNo++}`;
Expand Down
8 changes: 8 additions & 0 deletions packages/api-database/source/search/types/expressions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
value: any;
};

export type NotEqualExpression<TEntity> = {
property: keyof TEntity;
jsonFieldAccessor?: JsonFieldAccessor;
op: "notEqual";
value: any;
};

Check warning on line 22 in packages/api-database/source/search/types/expressions.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-database/source/search/types/expressions.ts#L16-L22

Added lines #L16 - L22 were not covered by tests
export type BetweenExpression<TEntity> = {
property: keyof TEntity;
jsonFieldAccessor?: JsonFieldAccessor;
Expand Down Expand Up @@ -75,6 +82,7 @@
| TrueExpression
| FalseExpression
| EqualExpression<TEntity>
| NotEqualExpression<TEntity>

Check warning on line 85 in packages/api-database/source/search/types/expressions.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-database/source/search/types/expressions.ts#L85

Added line #L85 was not covered by tests
| BetweenExpression<TEntity>
| GreaterThanEqualExpression<TEntity>
| LessThanEqualExpression<TEntity>
Expand Down
1 change: 1 addition & 0 deletions packages/api-http/source/controllers/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
.createQueryBuilder()
.select()
.where("attributes ? :validatorPublicKey", { validatorPublicKey: "validatorPublicKey" })
.andWhere("attributes->>:validatorPublicKey <> ''", { validatorPublicKey: "validatorPublicKey" })

Check warning on line 112 in packages/api-http/source/controllers/validators.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-http/source/controllers/validators.ts#L112

Added line #L112 was not covered by tests
.andWhere(
new ApiDatabaseContracts.Brackets((query) => {
query
Expand Down
Loading