Skip to content

Commit

Permalink
Merge pull request #122 from pinax-network/fix/cluster
Browse files Browse the repository at this point in the history
add database query to cluster request
  • Loading branch information
DenisCarriere authored Mar 12, 2024
2 parents 724d3ea + a4b1fc3 commit f230655
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sql/cluster.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SELECT
formatReadableSize(sum(primary_key_bytes_in_memory)) AS primary_keys_size,
any(engine) AS engine,
sum(bytes) AS bytes_size
FROM clusterAllReplicas(default, system.parts)
FROM clusterAllReplicas({database: String}, system.parts)
WHERE active
GROUP BY
database,
Expand Down
3 changes: 2 additions & 1 deletion sql/cluster.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { z } from "zod";
import { readOnlyClient } from "../src/clickhouse/createClient.js";
import { config } from "../src/config.js";

export const ClusterSchema = z.object({
count: z.number(),
Expand All @@ -13,6 +14,6 @@ export type ClusterSchema = z.infer<typeof ClusterSchema>;

export async function cluster() {
const query = await Bun.file(import.meta.dirname + "/cluster.sql").text()
const response = await readOnlyClient.query({ query, format: "JSONEachRow" });
const response = await readOnlyClient.query({ query, query_params: {database: config.database}, format: "JSONEachRow" });
return response.json();
}

0 comments on commit f230655

Please sign in to comment.