Skip to content

Commit

Permalink
add offset parameter to all path
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu Lefebvre committed Nov 14, 2023
1 parent fc5799a commit 1265269
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/fetch/openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ const parameterLimit: ParameterObject = {
schema: { type: "number", maximum: config.maxLimit, minimum: 1 },
}

const parameterOffset: ParameterObject = {
name: "offset",
in: "query",
description: "Used to offset data. Combined with limit can be used for pagination.",
required: false,
schema: { type: "number", minimum: 1 },
}


const timestampFilter = timestampExamplesArrayFilter.map(name => {
return {
Expand Down Expand Up @@ -118,6 +126,7 @@ export default new OpenApiBuilder()
...timestampFilter,
...blockFilter,
parameterLimit,
parameterOffset,
],
responses: {
200: { description: "Array of supply", content: { "application/json": { example: supply_example, schema: { type: "array" } } } },
Expand All @@ -137,6 +146,7 @@ export default new OpenApiBuilder()
...timestampFilter,
...blockFilter,
parameterLimit,
parameterOffset,
],
responses: {
200: { description: "Array of contracts", content: { "application/json": { example: contract_example, schema: { type: "array" } } } },
Expand All @@ -156,6 +166,7 @@ export default new OpenApiBuilder()
...timestampFilter,
...blockFilter,
parameterLimit,
parameterOffset,
],
responses: {
200: { description: "Array of balance changes", content: { "application/json": { example: balance_example, schema: { type: "array" } } } },
Expand All @@ -172,6 +183,7 @@ export default new OpenApiBuilder()
...timestampFilter,
...blockFilter,
parameterLimit,
parameterOffset,
],
responses: {
200: { description: "Array of holders", content: { "application/json": { example: holders_example, schema: { type: "array" } } } },
Expand Down
10 changes: 8 additions & 2 deletions src/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ export function getTotalSupply(searchParams: URLSearchParams, example?: boolean)
}
const limit = parseLimit(searchParams.get("limit"));
query += ` LIMIT ${limit} `

const offset = searchParams.get("offset");
if (offset) query += ` OFFSET ${offset} `
return query;
}

Expand Down Expand Up @@ -108,6 +109,8 @@ export function getContracts(searchParams: URLSearchParams, example?: boolean) {
}
const limit = parseLimit(searchParams.get("limit"));
query += ` LIMIT ${limit} `
const offset = searchParams.get("offset");
if (offset) query += ` OFFSET ${offset} `
return query;
}

Expand Down Expand Up @@ -160,6 +163,8 @@ export function getBalanceChanges(searchParams: URLSearchParams, example?: boole
}
const limit = parseLimit(searchParams.get("limit"), 100);
query += ` LIMIT ${limit} `
const offset = searchParams.get("offset");
if (offset) query += ` OFFSET ${offset} `
return query;
}

Expand Down Expand Up @@ -205,7 +210,8 @@ export function getHolders(searchParams: URLSearchParams, example?: boolean) {

const limit = parseLimit(searchParams.get("limit"), 100);
if (limit) query += ` LIMIT ${limit} `;

const offset = searchParams.get("offset");
if (offset) query += ` OFFSET ${offset} `
return query;
}

Expand Down

0 comments on commit 1265269

Please sign in to comment.