import { useState } from "react"; import { createFileRoute } from "@tanstack/react-router"; import { useTRPC } from "@/integrations/trpc/react"; import { useQuery } from "@tanstack/react-query"; import Header from "@/components/Header"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@bullstudio/ui/components/select"; import { Button } from "@bullstudio/ui/components/button"; import { Skeleton } from "@bullstudio/ui/components/skeleton"; import { RefreshCw, Layers, Database } from "lucide-react"; import { EmptyState } from "@bullstudio/ui/shared"; import { MetricCardsGrid } from "@/components/overview/MetricCardsGrid"; import { ThroughputChart } from "@/components/overview/ThroughputChart"; import { ProcessingTimeChart } from "@/components/overview/ProcessingTimeChart"; import { SlowestJobsTable } from "@/components/overview/SlowestJobsTable"; import { FailingJobTypesTable } from "@/components/overview/FailingJobTypesTable"; import dayjs from "@bullstudio/dayjs"; export const Route = createFileRoute("/")({ component: OverviewPage }); const TIME_RANGES = [ { value: "1", label: "Last 1h" }, { value: "6", label: "Last 6h" }, { value: "24", label: "Last 24h" }, { value: "72", label: "Last 3d" }, { value: "168", label: "Last 7d" }, ]; const ALL_QUEUES_VALUE = "__all__"; function OverviewPage() { const trpc = useTRPC(); const [queueName, setQueueName] = useState(""); const [timeRange, setTimeRange] = useState(24); const { data: queues, isLoading: loadingQueues } = useQuery( trpc.queues.list.queryOptions(), ); const { data: metrics, isLoading: loadingMetrics, refetch, isFetching, } = useQuery( trpc.overview.metrics.queryOptions({ timeRangeHours: timeRange, queueName: queueName || undefined, }), ); return (
{/* Header Controls */}
{metrics?.lastUpdated && ( Updated {dayjs(metrics.lastUpdated).fromNow()} )}
{/* Content */} {loadingMetrics ? ( ) : queues && queues.length === 0 ? ( } title="No queues found" description="No BullMQ queues were found in the connected Redis instance. Make sure you have queues set up." /> ) : metrics ? ( <>
) : null}
); } function OverviewSkeleton() { return (
{[...Array(4)].map((_, i) => ( ))}
); }