Skip to content
This repository has been archived by the owner on Oct 14, 2024. It is now read-only.

perf(ui): improve UI queries to reduce load time #1985

Merged
merged 1 commit into from
Aug 9, 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
2 changes: 1 addition & 1 deletion ui/src/layout/AssetScans/AssetScanDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const AssetScanDetails = () => (
<DetailsPageWrapper
backTitle="Asset scans"
url={APIS.ASSET_SCANS}
select="id,scan,asset,summary,status,stats,sbom,vulnerabilities,exploits,misconfigurations,secrets,malware,rootkits"
select="id,scan,asset,summary,status,stats,sbom/status,vulnerabilities/status,exploits/status,misconfigurations/status,secrets/status,malware/status,rootkits/status"
expand="scan($select=id,name,startTime,endTime),asset($select=id,assetInfo),status,stats"
getTitleData={({ scan, asset }) => {
const { startTime, name } = scan || {};
Expand Down
2 changes: 1 addition & 1 deletion ui/src/layout/Dashboard/CounterDisplay/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const ScanCounterDisplay = () => {
queryParams: {
$count: true,
$top: 1,
$select: "id",
$select: "count",
$filter:
"status/state eq 'Aborted' or status/state eq 'Failed' or status/state eq 'Done'",
},
Expand Down
6 changes: 4 additions & 2 deletions ui/src/layout/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ const COUNTERS_CONFIG = [
];

const Dashboard = () => {
const [{ data, error, loading }] = useFetch(APIS.SCANS);
const [{ data, error, loading }] = useFetch(APIS.SCANS, {
queryParams: { $count: true, $select: "count" },
});

if (loading) {
return <Loader />;
Expand All @@ -37,7 +39,7 @@ const Dashboard = () => {
return null;
}

if (data.length === 0) {
if (data.count === 0) {
return <EmptyScansDisplay />;
}

Expand Down
1 change: 1 addition & 0 deletions ui/src/layout/Findings/Exploits/ExploitsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const ExploitsTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_EXPLOITS}
filtersConfig={[
{
Expand Down
2 changes: 1 addition & 1 deletion ui/src/layout/Findings/FindingsDetailsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const FindingsDetailsPage = ({
<DetailsPageWrapper
backTitle={backTitle}
url={APIS.FINDINGS}
select="id,findingInfo,firstSeen,lastSeen,summary"
select="id,findingInfo,firstSeen,lastSeen"
getTitleData={getTitleData}
detailsContent={(props) => <DetailsContent {...props} />}
/>
Expand Down
2 changes: 2 additions & 0 deletions ui/src/layout/Findings/FindingsTablePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const FindingsTablePage = ({
columns,
filterType,
filtersConfig,
select,
}) => {
const filtersDispatch = useFilterDispatch();
const filtersState = useFilterState();
Expand Down Expand Up @@ -73,6 +74,7 @@ const FindingsTablePage = ({
<TablePage
columns={columns}
url={APIS.FINDINGS}
select={select}
tableTitle={tableTitle}
filterType={filterType}
filtersConfig={[
Expand Down
1 change: 1 addition & 0 deletions ui/src/layout/Findings/Malware/MalwareTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const MalwareTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_MALWARE}
filtersConfig={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const MisconfigurationsTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_MISCONFIGURATIONS}
filtersConfig={[
{
Expand Down
1 change: 1 addition & 0 deletions ui/src/layout/Findings/Packages/PackagesTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const PackagesTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_PACKAGES}
filtersConfig={[
{
Expand Down
1 change: 1 addition & 0 deletions ui/src/layout/Findings/Rootkits/RootkitsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const RootkitsTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_ROOTKITS}
filtersConfig={[
{
Expand Down
1 change: 1 addition & 0 deletions ui/src/layout/Findings/Secrets/SecretsTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const SecretsTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_SECRETS}
filtersConfig={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const VulnerabilitiesTable = () => {
return (
<FindingsTablePage
columns={columns}
select="id,findingInfo,firstSeen,lastSeen"
filterType={FILTER_TYPES.FINDINGS_VULNERABILITIES}
filtersConfig={[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const ConfigurationScansDisplay = ({ configId, configName }) => {
};

const [{ loading, data, error }] = useFetch(APIS.SCANS, {
queryParams: { $filter: scansFilter, $count: true },
queryParams: { $filter: scansFilter, $count: true, $select: "count" },
});

if (error) {
Expand Down
1 change: 1 addition & 0 deletions ui/src/layout/Scans/Scans/ScansTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ const ScansTable = () => {
<TablePage
columns={columns}
url={APIS.SCANS}
select="id,name,startTime,endTime,scope,status,summary"
tableTitle={TABLE_TITLE}
filterType={FILTER_TYPES.SCANS}
filtersConfig={[
Expand Down
14 changes: 11 additions & 3 deletions ui/src/layout/Scans/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ const ScansTabbedPage = () => {
}, [prevOpenConfigForm, openConfigForm, openDisplayModal]);

const [{ data, error, loading }, fetchData] = useMountMultiFetch([
{ key: "scans", url: APIS.SCANS },
{ key: "scanConfigs", url: APIS.SCAN_CONFIGS },
{
key: "scans",
url: APIS.SCANS,
queryParams: { $count: true, $select: "count" },
},
{
key: "scanConfigs",
url: APIS.SCAN_CONFIGS,
queryParams: { $count: true, $select: "count" },
},
]);

if (loading) {
Expand All @@ -63,7 +71,7 @@ const ScansTabbedPage = () => {

return (
<>
{scans?.length === 0 && scanConfigs?.total === 0 ? (
{scans?.count === 0 && scanConfigs?.count === 0 ? (
<EmptyDisplay
message={
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const AssetScansDisplay = ({ assetName, assetId }) => {
queryParams: {
$filter: filter,
$count: true,
$select: "id,asset,summary,scan",
$select: "count",
},
});

Expand Down