MCPcopy Create free account
hub / github.com/Datakitpage/Datakit / compareSize

Method compareSize

frontend/src/lib/api/postgresService.ts:256–277  ·  view source on GitHub ↗

* Helper to compare table sizes (rough approximation)

(size1: string, size2: string)

Source from the content-addressed store, hash-verified

254 * Helper to compare table sizes (rough approximation)
255 */
256 private compareSize(size1: string, size2: string): number {
257 const parseSize = (size: string): number => {
258 const match = size.match(/^([\d.]+)\s*(bytes?|KB|MB|GB|TB)?$/i);
259 if (!match) return 0;
260
261 const value = parseFloat(match[1]);
262 const unit = (match[2] || 'bytes').toLowerCase();
263
264 const multipliers: Record<string, number> = {
265 'bytes': 1,
266 'byte': 1,
267 'kb': 1024,
268 'mb': 1024 * 1024,
269 'gb': 1024 * 1024 * 1024,
270 'tb': 1024 * 1024 * 1024 * 1024,
271 };
272
273 return value * (multipliers[unit] || 1);
274 };
275
276 return parseSize(size1) - parseSize(size2);
277 }
278
279 /**
280 * Execute a simple SELECT query with error handling

Callers 1

getConnectionStatsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected