Skip to content

Commit 162344c

Browse files
author
Roman M
committed
Remove Dead code
1 parent c8b56ab commit 162344c

File tree

4 files changed

+0
-133
lines changed

4 files changed

+0
-133
lines changed

pkg/resource_handlers.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,15 +1130,6 @@ func sendUniversalErrorResponse(sender backend.CallResourceResponseSender, ctx E
11301130
})
11311131
}
11321132

1133-
// Legacy function for backward compatibility
1134-
func checkUnreplacedMacros(sql string, originalErr error) string {
1135-
unreplacedMacros := findUnreplacedMacros(sql)
1136-
if len(unreplacedMacros) > 0 {
1137-
return fmt.Sprintf("%v [Warning: Query contains unreplaced macros: %s - this usually means query processing failed before macro replacement could complete]",
1138-
originalErr, strings.Join(unreplacedMacros, ", "))
1139-
}
1140-
return originalErr.Error()
1141-
}
11421133

11431134
// handleCreateQueryWithAdhoc safely batches createQuery + applyAdhocFilters without property extraction
11441135
func (ds *ClickHouseDatasource) handleCreateQueryWithAdhoc(ctx context.Context, req *backend.CallResourceRequest, sender backend.CallResourceResponseSender) error {
Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +0,0 @@
1-
export class SimpleCache {
2-
// The key under which the cache is stored in sessionStorage
3-
private storageKey = 'simpleCache';
4-
5-
// In-memory cache
6-
private cache: { [key: string]: any } = {};
7-
8-
constructor() {
9-
this.loadCache();
10-
}
11-
12-
/**
13-
* Retrieves the cached value for a given key-object pair.
14-
* @param key The string key.
15-
* @param obj The object to namespace the key.
16-
* @returns The cached value if found; otherwise, null.
17-
*/
18-
public get(key: string, obj: object): any | null {
19-
const compositeKey = this.createCompositeKey(key, obj);
20-
if (compositeKey in this.cache) {
21-
return this.cache[compositeKey];
22-
}
23-
return null;
24-
}
25-
26-
/**
27-
* Stores a value in the cache for a given key-object pair.
28-
* @param key The string key.
29-
* @param obj The object to namespace the key.
30-
* @param value The value to cache.
31-
*/
32-
public set(key: string, obj: object, value: any): void {
33-
const compositeKey = this.createCompositeKey(key, obj);
34-
this.cache[compositeKey] = value;
35-
this.saveCache();
36-
}
37-
38-
/**
39-
* Clears the entire cache both in-memory and in sessionStorage.
40-
*/
41-
public clear(): void {
42-
this.cache = {};
43-
sessionStorage.removeItem(this.storageKey);
44-
}
45-
46-
/**
47-
* Creates a composite key by combining the key and a stable string representation of the object.
48-
* @param key The string key.
49-
* @param obj The object to namespace the key.
50-
* @returns The composite key as a string.
51-
*/
52-
private createCompositeKey(key: string, obj: object): string {
53-
const serializedObj = this.stableStringify(obj);
54-
return `${key}|${serializedObj}`;
55-
}
56-
57-
/**
58-
* Loads the cache from sessionStorage into the in-memory cache.
59-
*/
60-
private loadCache(): void {
61-
const storedCache = sessionStorage.getItem(this.storageKey);
62-
if (storedCache) {
63-
try {
64-
this.cache = JSON.parse(storedCache);
65-
} catch (error) {
66-
console.error('Failed to parse cache from sessionStorage:', error);
67-
this.cache = {};
68-
}
69-
}
70-
}
71-
72-
/**
73-
* Saves the in-memory cache to sessionStorage.
74-
*/
75-
private saveCache(): void {
76-
try {
77-
sessionStorage.setItem(this.storageKey, JSON.stringify(this.cache));
78-
} catch (error) {
79-
console.error('Failed to save cache to sessionStorage:', error);
80-
}
81-
}
82-
83-
/**
84-
* Serializes an object into a JSON string with sorted keys to ensure consistency.
85-
* @param obj The object to serialize.
86-
* @returns A JSON string with sorted keys.
87-
*/
88-
private stableStringify(obj: any): string {
89-
if (obj !== null && typeof obj === 'object') {
90-
if (Array.isArray(obj)) {
91-
return `[${obj.map((item) => this.stableStringify(item)).join(',')}]`;
92-
} else {
93-
const keys = Object.keys(obj).sort();
94-
return `{${keys.map((key) => `"${key}":${this.stableStringify(obj[key])}`).join(',')}}`;
95-
}
96-
} else if (typeof obj === 'string') {
97-
return `"${obj}"`;
98-
} else {
99-
return String(obj);
100-
}
101-
}
102-
}

src/datasource/sql-query/sql-query-helper.ts

Whitespace-only changes.

src/utils/clickhouseErrorHandling.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -113,25 +113,3 @@ export function getPermissionErrorMessage(
113113
return baseMessage;
114114
}
115115

116-
/**
117-
* Handles a permission error by logging it appropriately and returning a safe default value
118-
* @param error - The error to handle
119-
* @param context - The context where the error occurred
120-
* @param datasourceId - Optional datasource identifier
121-
* @param defaultValue - The default value to return (default: [])
122-
* @returns The default value
123-
*/
124-
export function handlePermissionError<T = any[]>(
125-
error: any,
126-
context: PermissionErrorContextType,
127-
datasourceId?: string,
128-
defaultValue: T = [] as any
129-
): T {
130-
if (isPermissionError(error)) {
131-
console.info(getPermissionErrorMessage(context, datasourceId));
132-
return defaultValue;
133-
}
134-
135-
// If it's not a permission error, re-throw it
136-
throw error;
137-
}

0 commit comments

Comments
 (0)