Skip to content

Commit

Permalink
fix where statement
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisCarriere committed Sep 23, 2024
1 parent 0aa4c2e commit 44891ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import { APIErrorResponse } from "./src/utils.js";
import { usageOperationsToEndpointsMap, type EndpointReturnTypes, type UsageEndpoints } from "./src/types/api.js";
import { paths } from './src/types/zod.gen.js';

await client.ping().then((result) => {
if (!result.success) {
logger.error(`Failed to connect to ClickHouse: ${result.error.message}`);
process.exit(1);
}
});

async function AntelopeTransactionsAPI() {
const app = new Hono();

Expand Down
5 changes: 3 additions & 2 deletions src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
for (let key in query_params) {
if (["limit", "offset", "order_by", "order_direction", "skip", "first"].includes(key)) continue; // skip pagination params
const value = (query_params as any)[key];
where.push(`${key} = {${key}: ${typeof value === "number" ? "int" : "String"}}`);
let isNumber = !isNaN(Number(value));
where.push(`"${key}" = {${key}: ${isNumber ? "int" : "String"}}`);
}
if (where.length) query.push(`WHERE ${where.join(" AND ")}`);

Expand All @@ -48,4 +49,4 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
} catch (err) {
return APIErrorResponse(ctx, 500, "bad_database_response", err);
}
}
}

0 comments on commit 44891ed

Please sign in to comment.