Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@ import type { MetricsDataPoint } from "../../common/MetricsChart/useMetrics";
interface DestinationEventsCellProps {
metricsData?: MetricsDataPoint[];
isLoading: boolean;
sampleCount: number;
}

const EMPTY_SERIES_SAMPLE_COUNT = 6;

function formatCount(n: number): string {
if (n >= 1_000_000) return `${(n / 1_000_000).toFixed(1)}M`;
if (n >= 1_000) return `${(n / 1_000).toFixed(1)}k`;
Expand All @@ -17,6 +16,7 @@ function formatCount(n: number): string {
const DestinationEventsCell: React.FC<DestinationEventsCellProps> = ({
metricsData,
isLoading,
sampleCount,
}) => {
if (isLoading || !metricsData) {
return <span className="histogram-cell__loading"></span>;
Expand All @@ -28,7 +28,7 @@ const DestinationEventsCell: React.FC<DestinationEventsCellProps> = ({
successful: d.metrics.successful_count ?? 0,
failed: d.metrics.failed_count ?? 0,
}))
: Array.from({ length: EMPTY_SERIES_SAMPLE_COUNT }, () => ({
: Array.from({ length: sampleCount }, () => ({
successful: 0,
failed: 0,
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import type { Destination } from "../../typings/Destination";
import getLogo from "../../utils/logo";
import DestinationEventsCell from "./DestinationEventsCell";

const DEFAULT_METRICS_SAMPLE_COUNT = 7;

const DestinationList: React.FC = () => {
const { data: destinations } = useSWR<Destination[]>("destinations");
const destination_types = useDestinationTypes();
Expand All @@ -35,6 +37,9 @@ const DestinationList: React.FC = () => {
filters: {},
},
);
const metricsSampleCount =
Object.values(batchedMetrics ?? {}).find((points) => points.length > 0)
?.length ?? DEFAULT_METRICS_SAMPLE_COUNT;

const [searchTerm, setSearchTerm] = useState("");
const [selectedStatus, setSelectedStatus] = useState<Record<string, boolean>>(
Expand Down Expand Up @@ -146,6 +151,7 @@ const DestinationList: React.FC = () => {
: undefined
}
isLoading={metricsLoading}
sampleCount={metricsSampleCount}
/>,
].filter((entry) => entry !== null),
link: `/destinations/${destination.id}`,
Expand Down
Loading