Skip to content

Commit

Permalink
fix(core-api): return count of filtered peers (#2814)
Browse files Browse the repository at this point in the history
  • Loading branch information
dated authored and faustbrian committed Jul 17, 2019
1 parent 5adf23d commit 3363fe7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/core-api/src/handlers/peers/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ export class PeersController extends Controller {
result = request.query.version
? result.filter(peer => peer.version === (request.query as any).version)
: result;

const count: number = result.length;

result = result.slice(0, +request.query.limit || 100);

const orderBy: string = request.query.orderBy as string;
Expand All @@ -26,7 +29,7 @@ export class PeersController extends Controller {
}
}

return super.toPagination({ rows: result, count: allPeers.length }, "peer");
return super.toPagination({ rows: result, count }, "peer");
}

public async show(request: Hapi.Request, h: Hapi.ResponseToolkit) {
Expand Down
2 changes: 0 additions & 2 deletions packages/core-api/src/handlers/peers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ export const index: object = {
...pagination,
...{
ip: Joi.string().ip(),
status: Joi.string(),
port: Joi.number().port(),
version: Joi.string(),
orderBy: Joi.string(),
},
Expand Down

0 comments on commit 3363fe7

Please sign in to comment.