MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / labelFromQueryKey

Function labelFromQueryKey

console/e2e-tests/scalability/helpers.ts:110–129  ·  view source on GitHub ↗

* `hashKey` from @tanstack/react-query JSON-stringifies (not hashes), so * `query_key` is a readable array of `{scope, ...}` parts. Joined: `clusters.list`.

(request: Request)

Source from the content-addressed store, hash-verified

108 * `query_key` is a readable array of `{scope, ...}` parts. Joined: `clusters.list`.
109 */
110function labelFromQueryKey(request: Request): string | undefined {
111 try {
112 const url = new URL(request.url());
113 const raw = url.searchParams.get("query_key");
114 if (!raw) return undefined;
115 const parsed = JSON.parse(raw);
116 if (!Array.isArray(parsed)) return undefined;
117 const scopes = parsed
118 .map((part) =>
119 part && typeof part === "object" && typeof part.scope === "string"
120 ? part.scope
121 : undefined,
122 )
123 .filter((s): s is string => !!s);
124 if (scopes.length === 0) return undefined;
125 return scopes.join(".");
126 } catch {
127 return undefined;
128 }
129}
130
131function labelFromSql(sql: string): string | undefined {
132 for (const [label, pattern] of SQL_LABELS) {

Callers 1

labelRequestFunction · 0.85

Calls 6

urlMethod · 0.45
getMethod · 0.45
parseMethod · 0.45
filterMethod · 0.45
mapMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected