Skip to content

Commit

Permalink
[api] add skip/limit to get_tokens
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Lins e Silva committed Jul 27, 2020
1 parent 3a7d422 commit 0247275
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions api/routes/v2-state/get_tokens/get_tokens.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import {ServerResponse} from "http";
import {timedQuery} from "../../../helpers/functions";
import {FastifyInstance, FastifyReply, FastifyRequest} from "fastify";
import {getSkipLimit} from "../../v2-history/get_actions/functions";


async function getTokens(fastify: FastifyInstance, request: FastifyRequest) {

const response = {'account': request.query.account, 'tokens': []};

const {skip, limit} = getSkipLimit(request.query);
const maxDocs = fastify.manager.config.api.limits.get_tokens ?? 100;

const stateResult = await fastify.elastic.search({
"index": fastify.manager.chain + '-table-accounts-*',
"size": (limit > maxDocs ? maxDocs : limit) || 10,
"from": skip || 0,
"body": {
query: {
bool: {
Expand Down

0 comments on commit 0247275

Please sign in to comment.