-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add expensive-queries, format number, refactor menu and data-table
- Loading branch information
Showing
10 changed files
with
284 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { fetchData } from '@/lib/clickhouse' | ||
import { Badge } from '@/components/ui/badge' | ||
|
||
interface CountBadgeProps { | ||
sql?: string | ||
} | ||
|
||
export async function CountBadge({ | ||
sql, | ||
}: CountBadgeProps): Promise<JSX.Element | null> { | ||
if (!sql) return null | ||
|
||
let data: any[] = [] | ||
|
||
try { | ||
data = await fetchData(sql) | ||
} catch (e: any) { | ||
console.error(`Could not get count for sql: ${sql}, error: ${e}`) | ||
return null | ||
} | ||
|
||
if (!data || !data.length || !data?.[0]?.['count()']) return null | ||
|
||
const count = data[0]['count()'] || data[0]['count'] || 0 | ||
if (count === 0) return null | ||
|
||
return ( | ||
<Badge className="ml-2" variant="outline"> | ||
{count} | ||
</Badge> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.