Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: utilisation du champs "fields" #566

Merged
merged 4 commits into from
Dec 2, 2024
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
8 changes: 8 additions & 0 deletions assets/@types/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export enum DatasheetDocumentTypeEnum {
Link = "link",
}

// type PartialVectorDb = Pick<VectorDb, "name" | "description" | "type" | "visibility" | "status" | "srs" | "contact" | "size" | "last_event" | "tags"> & {
// bbox?: BoundingBox;
// };

// type PartialPyramid = Pick<Pyramid, "name" | "description" | "type" | "visibility" | "status" | "srs" | "contact" | "size" | "last_event" | "tags"> & {
// bbox?: BoundingBox;
// };

export type DatasheetDetailed = Datasheet & {
vector_db_list: VectorDb[] | undefined;
pyramid_list: Pyramid[] | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const DatasheetList: FC<DatasheetListProps> = ({ datastoreId }) => {
const datasheetListQuery = useQuery({
queryKey: RQKeys.datastore_datasheet_list(datastoreId),
queryFn: ({ signal }) => api.datasheet.getList(datastoreId, { signal }),
staleTime: 30000,
refetchInterval: 30000,
staleTime: 60000,
refetchInterval: 60000,
enabled: datastoreQuery.data !== undefined,
});

Expand Down
20 changes: 13 additions & 7 deletions assets/entrepot/pages/datasheet/DatasheetView/DatasheetView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ const DatasheetView: FC<DatasheetViewProps> = ({ datastoreId, datasheetName }) =
const metadataQuery = useQuery<Metadata, CartesApiException>({
queryKey: RQKeys.datastore_metadata_by_datasheet_name(datastoreId, datasheetName),
queryFn: ({ signal }) => api.metadata.getByDatasheetName(datastoreId, datasheetName, { signal }),
enabled: !datasheetQuery.isFetching && !datasheetDeleteMutation.isPending,
enabled: !datasheetDeleteMutation.isPending,
staleTime: 60000,
retry: false,
});

const documentsListQuery = useQuery({
queryKey: RQKeys.datastore_datasheet_documents_list(datastoreId, datasheetName),
queryFn: ({ signal }) => api.datasheetDocument.getList(datastoreId, datasheetName, { signal }),
staleTime: 60000,
enabled: activeTab === DatasheetViewActiveTabEnum.Documents,
staleTime: 120000,
enabled: !datasheetDeleteMutation.isPending,
});

return (
Expand Down Expand Up @@ -171,7 +171,7 @@ const DatasheetView: FC<DatasheetViewProps> = ({ datastoreId, datasheetName }) =
tabId: DatasheetViewActiveTabEnum.Dataset,
},
{
label: t("tab_label.services", { num: datasheetQuery.data?.service_list?.length || 0 }),
label: t("tab_label.services", { num: datasheetQuery.data.service_list?.length || 0 }),
tabId: DatasheetViewActiveTabEnum.Services,
},
{
Expand All @@ -193,7 +193,13 @@ const DatasheetView: FC<DatasheetViewProps> = ({ datastoreId, datasheetName }) =
return <DatasetListTab datastoreId={datastoreId} datasheet={datasheetQuery.data} />;

case DatasheetViewActiveTabEnum.Services:
return <ServicesListTab datastoreId={datastoreId} datasheet={datasheetQuery.data} />;
return (
<ServicesListTab
datastoreId={datastoreId}
datasheet={datasheetQuery.data}
datasheet_services_list={datasheetQuery.data.service_list ?? []}
/>
);

case DatasheetViewActiveTabEnum.Documents:
return <DocumentsTab datastoreId={datastoreId} datasheetName={datasheetName} />;
Expand Down Expand Up @@ -240,8 +246,8 @@ const DatasheetView: FC<DatasheetViewProps> = ({ datastoreId, datasheetName }) =
{datasheetQuery?.data?.pyramid_list?.length && datasheetQuery?.data?.pyramid_list.length > 0 ? (
<li>{datasheetQuery?.data?.pyramid_list.length} pyramide(s) de tuiles vectorielles</li>
) : null}
{datasheetQuery?.data?.service_list?.length && datasheetQuery?.data?.service_list.length > 0 ? (
<li>{datasheetQuery?.data?.service_list.length} service(s) publié(s)</li>
{datasheetQuery.data?.service_list?.length && datasheetQuery.data.service_list.length > 0 ? (
<li>{datasheetQuery.data?.service_list.length} service(s) publié(s)</li>
) : null}
{datasheetQuery?.data?.upload_list?.length && datasheetQuery?.data?.upload_list.length > 0 ? (
<li>{datasheetQuery?.data?.upload_list.length} livraison(s)</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,24 @@ import { FC } from "react";
import { symToStr } from "tsafe/symToStr";

import Translator from "../../../../../modules/Translator";
import { DatasheetDetailed } from "../../../../../@types/app";
import { DatasheetDetailed, Service } from "../../../../../@types/app";
import ServicesListItem from "./ServicesListItem";

type ServicesListTabProps = {
datasheet: DatasheetDetailed;
datastoreId: string;
datasheet_services_list: Service[];
};
const ServicesListTab: FC<ServicesListTabProps> = ({ datastoreId, datasheet }) => {
if (!datasheet?.service_list || datasheet?.service_list.length === 0) {
const ServicesListTab: FC<ServicesListTabProps> = ({ datastoreId, datasheet, datasheet_services_list }) => {
if (!datasheet_services_list || datasheet_services_list.length === 0) {
return (
<div className={fr.cx("fr-grid-row", "fr-grid-row--middle")}>
<p>{Translator.trans("datasheet.view.services.no_service")}</p>
</div>
);
}

return datasheet?.service_list?.map((service) => (
return datasheet_services_list?.map((service) => (
<ServicesListItem key={service._id} service={service} datasheetName={datasheet.name} datastoreId={datastoreId} />
));
};
Expand Down
Loading