Skip to content

Commit

Permalink
feat: add indicators for selectivity
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyashankar committed Nov 14, 2024
1 parent c52db12 commit 6bee8f6
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 4 deletions.
53 changes: 51 additions & 2 deletions website/src/components/Output.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, { useState, useEffect, useMemo } from "react";
import { ColumnType } from "@/components/ResizableDataTable";
import ResizableDataTable from "@/components/ResizableDataTable";
import { usePipelineContext } from "@/contexts/PipelineContext";
import { Loader2, Download, ChevronDown } from "lucide-react";
import { Loader2, Download, ChevronDown, Circle } from "lucide-react";
import { Button } from "@/components/ui/button";
import { Progress } from "@/components/ui/progress";
import BookmarkableText from "@/components/BookmarkableText";
Expand All @@ -19,6 +19,47 @@ import { useWebSocket } from "@/contexts/WebSocketContext";
import AnsiRenderer from "./AnsiRenderer";
import clsx from "clsx";

const TinyPieChart: React.FC<{ percentage: number }> = ({ percentage }) => {
const size = 16;
const radius = 6;
const strokeWidth = 2;
const center = size / 2;
const circumference = 2 * Math.PI * radius;
const strokeDasharray = `${
(percentage * circumference) / 100
} ${circumference}`;

return (
<div className="relative w-4 h-4 flex items-center justify-center">
<svg
className="w-4 h-4 -rotate-90"
viewBox={`0 0 ${size} ${size}`}
width={size}
height={size}
>
<circle
cx={center}
cy={center}
r={radius}
className="fill-none stroke-gray-200"
strokeWidth={strokeWidth}
/>
<circle
cx={center}
cy={center}
r={radius}
className={clsx(
"fill-none transition-all duration-500 ease-out",
percentage > 100 ? "stroke-emerald-500" : "stroke-rose-500"
)}
strokeWidth={strokeWidth}
strokeDasharray={strokeDasharray}
/>
</svg>
</div>
);
};

export const ConsoleContent: React.FC = () => {
const { terminalOutput, setTerminalOutput, optimizerProgress } =
usePipelineContext();
Expand Down Expand Up @@ -442,7 +483,7 @@ export const Output: React.FC = () => {
<TooltipProvider>
<Tooltip>
<TooltipTrigger>
<div className="flex items-center px-2 py-1 border border-gray-200 rounded-md">
<div className="flex items-center px-2 py-1 border border-gray-200 rounded-md cursor-help">
<span
className={clsx(
"font-medium",
Expand All @@ -457,6 +498,14 @@ export const Output: React.FC = () => {
>
{selectivityFactor}×
</span>
{selectivityFactor !== "N/A" &&
Number(selectivityFactor) < 1 && (
<div className="ml-1">
<TinyPieChart
percentage={Number(selectivityFactor) * 100}
/>
</div>
)}
</div>
</TooltipTrigger>
<TooltipContent>
Expand Down
13 changes: 11 additions & 2 deletions website/src/components/operations/args.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,9 +471,18 @@ export const CodeInput: React.FC<CodeInputProps> = React.memo(
</Tooltip>
</TooltipProvider>
</div>
<div className="border">
<div
className="border"
style={{
resize: "vertical",
overflow: "auto",
minHeight: "200px",
height: "200px", // Set initial height explicitly
backgroundColor: "var(--background)", // Match editor background
}}
>
<Editor
height="200px"
height="100%"
defaultLanguage="python"
value={code || getPlaceholder()}
onChange={(value) => onChange(value || "")}
Expand Down

0 comments on commit 6bee8f6

Please sign in to comment.