Skip to content

Commit 859c16e

Browse files
authored
feat: add retrievability filter (http and rpa) for score compliance dashboards
* Add retrievability filter (http and rpa) for score compliance dashboards * Remove retrieval rate colum from reports views * Change query retrievabilityType value
1 parent 89fc3a0 commit 859c16e

File tree

5 files changed

+83
-88
lines changed

5 files changed

+83
-88
lines changed

src/app/allocators/(pages)/[id]/(pages)/reports/(pages)/[...report]/components/provider-view/provider-table.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -165,31 +165,6 @@ const useReportViewProvidersColumns = (/*compareMode: boolean*/) => {
165165
);
166166
},
167167
},
168-
{
169-
accessorKey: "retrievability_success_rate",
170-
header: () => {
171-
return <div className="whitespace-nowrap">Retrieval Rate</div>;
172-
},
173-
cell: ({ row }) => {
174-
if (row.original.not_found) {
175-
return (
176-
<div className="h-full flex items-center justify-end gap-1">
177-
N/A
178-
</div>
179-
);
180-
}
181-
182-
const successRate = row.getValue(
183-
"retrievability_success_rate"
184-
) as number;
185-
186-
return (
187-
<div className="h-full flex items-center justify-end gap-1">
188-
<span>{(successRate * 100).toFixed(2)}%</span>
189-
</div>
190-
);
191-
},
192-
},
193168
{
194169
accessorKey: "retrievability_success_rate_http",
195170
header: () => {

src/app/clients/(pages)/[id]/(pages)/reports/(pages)/[...report]/components/provider-view/report-view-provider-table.tsx

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -248,36 +248,6 @@ const useReportViewProvidersColumns = (compareMode: boolean) => {
248248
);
249249
},
250250
},
251-
{
252-
accessorKey: "retrievability_success_rate",
253-
header: () => {
254-
return <div className="whitespace-nowrap">Retrieval Rate</div>;
255-
},
256-
cell: ({ row }) => {
257-
if (row.original.not_found) {
258-
return (
259-
<div className="h-full flex items-center justify-end gap-1">
260-
N/A
261-
</div>
262-
);
263-
}
264-
265-
const successRate = row.getValue(
266-
"retrievability_success_rate"
267-
) as number;
268-
269-
return (
270-
<div className="h-full flex items-center justify-center gap-1">
271-
<span>{(successRate * 100).toFixed(2)}%</span>
272-
{compareMode && (
273-
<CompareIcon
274-
compare={row.original.retrievability_success_rate_compare}
275-
/>
276-
)}
277-
</div>
278-
);
279-
},
280-
},
281251
{
282252
accessorKey: "retrievability_success_rate_http",
283253
header: () => {

src/app/compliance-data-portal/(pages)/allocators/retrievability/page.tsx

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { ChartWrapper } from "@/app/compliance-data-portal/components/chart-wrapper";
44
import { EditionRoundCheckbox } from "@/app/compliance-data-portal/components/edition-round-checkbox";
55
import { StackedBarGraph } from "@/app/compliance-data-portal/components/graphs/stacked-bar-graph";
6+
import { RetrievabilityTypeSelect } from "@/app/compliance-data-portal/components/retrievability-type-select";
67
import useWeeklyChartData from "@/app/compliance-data-portal/hooks/useWeeklyChartData";
78
import { Checkbox } from "@/components/ui/checkbox";
89
import { useAllocatorRetrievability } from "@/lib/hooks/cdp.hooks";
@@ -14,17 +15,17 @@ import { type ComponentProps, useCallback, useEffect, useState } from "react";
1415
type CheckboxProps = ComponentProps<typeof Checkbox>;
1516
type CheckedChangeHandler = NonNullable<CheckboxProps["onCheckedChange"]>;
1617

17-
const httpRetrievabilityFilterKey = "httpRetrievability";
18+
const retrievabilityFilterKey = "retrievabilityType";
1819
const openDataFilterKey = "openDataOnly";
1920

2021
export default function AllocatorRetrievabilityPage() {
2122
const { filters, updateFilter } = useSearchParamsFilters();
22-
const httpRetrievability = filters[httpRetrievabilityFilterKey] === "true";
23+
const retrievabilityType = filters[retrievabilityFilterKey] ?? "urlFinder";
2324
const openDataOnly = filters[openDataFilterKey] === "true";
2425
const [usePercentage, setUsePercentage] = useState(false);
2526

2627
const { data, isLoading } = useAllocatorRetrievability({
27-
httpRetrievability,
28+
retrievabilityType,
2829
openDataOnly,
2930
});
3031

@@ -45,17 +46,6 @@ export default function AllocatorRetrievabilityPage() {
4546
const { scale, calcPercentage, selectedScale, setSelectedScale } =
4647
useChartScale(minValue);
4748

48-
const handleHTTPRetrievabilityToggleChange =
49-
useCallback<CheckedChangeHandler>(
50-
(state) => {
51-
updateFilter(
52-
httpRetrievabilityFilterKey,
53-
state === true ? "true" : undefined
54-
);
55-
},
56-
[updateFilter]
57-
);
58-
5949
const handleOpenDataToggleChange = useCallback<CheckedChangeHandler>(
6050
(state) => {
6151
updateFilter(openDataFilterKey, state === true ? "true" : undefined);
@@ -86,19 +76,12 @@ export default function AllocatorRetrievabilityPage() {
8676
additionalFilters={[
8777
<div
8878
key="http-retrievability-toggle"
89-
className="flex items-center space-x-2 py-3.5 px-2"
79+
className="flex items-center space-x-2"
9080
>
91-
<Checkbox
92-
id="http-retrievability"
93-
checked={httpRetrievability}
94-
onCheckedChange={handleHTTPRetrievabilityToggleChange}
81+
<RetrievabilityTypeSelect
82+
label="Retrievability Type"
83+
defaultValue="urlFinder"
9584
/>
96-
<label
97-
className="text-sm font-medium leading-none"
98-
htmlFor="http-retrievability"
99-
>
100-
HTTP Retrievability
101-
</label>
10285
</div>,
10386
<div
10487
key="open-data-toggle"
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
"use client";
2+
3+
import {
4+
Select,
5+
SelectContent,
6+
SelectItem,
7+
SelectTrigger,
8+
SelectValue,
9+
} from "@/components/ui/select";
10+
import { useSearchParamsFilters } from "@/lib/hooks/use-search-params-filters";
11+
import { useCallback, type ReactNode } from "react";
12+
13+
export interface RetrievabilityTypeSelectProps {
14+
defaultValue?: string;
15+
label?: ReactNode;
16+
queryParamName?: string;
17+
}
18+
19+
const retrievabilityType = ["http", "urlFinder"] as const;
20+
const availableValues = retrievabilityType as unknown as string[];
21+
22+
export function RetrievabilityTypeSelect({
23+
defaultValue = "urlFinder",
24+
label = null,
25+
queryParamName = "retrievabilityType",
26+
}: RetrievabilityTypeSelectProps) {
27+
const { filters, updateFilter } = useSearchParamsFilters();
28+
29+
const value =
30+
!!filters[queryParamName] &&
31+
availableValues.includes(filters[queryParamName])
32+
? filters[queryParamName]
33+
: defaultValue;
34+
35+
const handleRetrievabilityTypeChange = useCallback(
36+
(value: string) => {
37+
updateFilter(queryParamName, value);
38+
},
39+
[updateFilter, queryParamName]
40+
);
41+
42+
return (
43+
<div className="flex items-center w-fit">
44+
{!!label && <span className="mr-2">{label}</span>}
45+
46+
<Select value={value} onValueChange={handleRetrievabilityTypeChange}>
47+
<SelectTrigger className="bg-white text-black border border-gray-300 hover:bg-gray-100 gap-2 w-[150px]">
48+
<SelectValue placeholder="Select..." />
49+
</SelectTrigger>
50+
<SelectContent>
51+
{availableValues.map((type) => (
52+
<SelectItem
53+
key={`select_item_retrieveability_type_${type}`}
54+
value={type}
55+
>
56+
{type === "urlFinder" ? "RPA" : "HTTP"}
57+
</SelectItem>
58+
))}
59+
</SelectContent>
60+
</Select>
61+
</div>
62+
);
63+
}

src/lib/hooks/cdp.hooks.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,21 @@ const allocatorSPsComplianceMetrics = [
3030
] as const;
3131

3232
interface UseStorageProviderRetrievabilityParameters {
33-
httpRetrievability?: boolean;
33+
retrievabilityType?: string;
3434
openDataOnly?: boolean;
3535
}
3636

3737
const useStorageProviderRetrievability = ({
38-
httpRetrievability = false,
38+
retrievabilityType = undefined,
3939
openDataOnly = false,
4040
}: UseStorageProviderRetrievabilityParameters) => {
4141
const { selectedRoundId } = useEditionRound();
4242

4343
const fetchData = useCallback(async () => {
4444
const searchParams = new URLSearchParams();
45-
searchParams.set("httpRetrievability", String(httpRetrievability));
45+
if (retrievabilityType)
46+
searchParams.set("retrievabilityType", String(retrievabilityType));
47+
4648
searchParams.set("openDataOnly", String(openDataOnly));
4749

4850
if (selectedRoundId) searchParams.set("editionId", selectedRoundId);
@@ -55,7 +57,7 @@ const useStorageProviderRetrievability = ({
5557
count: data?.histogram?.total,
5658
buckets: data?.histogram?.results,
5759
} as ICDPUnifiedHistogram;
58-
}, [httpRetrievability, openDataOnly, selectedRoundId]);
60+
}, [retrievabilityType, openDataOnly, selectedRoundId]);
5961

6062
const [data, setData] = useState<ICDPUnifiedHistogram | undefined>(undefined);
6163
const [isLoading, setIsLoading] = useState(false);
@@ -141,19 +143,21 @@ const useStorageProviderBiggestDeal = () => {
141143
};
142144

143145
interface UseAllocatorRetrievabilityParameters {
144-
httpRetrievability?: boolean;
146+
retrievabilityType?: string;
145147
openDataOnly?: boolean;
146148
}
147149

148150
const useAllocatorRetrievability = ({
149-
httpRetrievability = false,
151+
retrievabilityType = undefined,
150152
openDataOnly = false,
151153
}: UseAllocatorRetrievabilityParameters) => {
152154
const { selectedRoundId } = useEditionRound();
153155

154156
const fetchData = useCallback(async () => {
155157
const searchParams = new URLSearchParams();
156-
searchParams.set("httpRetrievability", String(httpRetrievability));
158+
if (retrievabilityType)
159+
searchParams.set("retrievabilityType", String(retrievabilityType));
160+
157161
searchParams.set("openDataOnly", String(openDataOnly));
158162
if (selectedRoundId) searchParams.set("editionId", selectedRoundId);
159163

@@ -166,7 +170,7 @@ const useAllocatorRetrievability = ({
166170
count: data?.histogram?.total,
167171
buckets: data?.histogram?.results,
168172
} as ICDPUnifiedHistogram;
169-
}, [httpRetrievability, openDataOnly, selectedRoundId]);
173+
}, [retrievabilityType, openDataOnly, selectedRoundId]);
170174

171175
const [data, setData] = useState<ICDPUnifiedHistogram | undefined>(undefined);
172176
const [isLoading, setIsLoading] = useState(false);

0 commit comments

Comments
 (0)