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

[Manual Backport] Allow arbitrary report record counts #427

Merged
merged 2 commits into from
Sep 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 .cypress/integration/02-edit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
'/reports-dashboards'
);

cy.wait(12500);

Check failure on line 14 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

cy.get('#reportDefinitionDetailsLink').first().click();

Expand All @@ -21,17 +21,17 @@

cy.url().should('include', 'edit');

cy.wait(1000);

Check failure on line 24 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// update the report name
cy.get('#reportSettingsName').type(' update name');
cy.get('#reportSettingsName').type(' update name', { force: true });

Check warning on line 27 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

// update report description
cy.get('#reportSettingsDescription').type(' update description');

cy.get('#editReportDefinitionButton').click({ force: true });

Check warning on line 32 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.wait(12500);

Check failure on line 34 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
Expand All @@ -44,7 +44,7 @@
'/reports-dashboards'
);

cy.wait(12500);

Check failure on line 47 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

cy.get('#reportDefinitionDetailsLink').first().click();

Expand All @@ -54,13 +54,13 @@

cy.url().should('include', 'edit');

cy.wait(1000);

Check failure on line 57 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods
cy.get('#reportDefinitionTriggerTypes > div:nth-child(2)').click({ force: true });

Check warning on line 58 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.get('#Schedule').check({ force: true });

Check warning on line 60 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls
cy.get('#editReportDefinitionButton').click({ force: true });

Check warning on line 61 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.wait(12500);

Check failure on line 63 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
Expand All @@ -73,7 +73,7 @@
'/reports-dashboards'
);

cy.wait(12500);

Check failure on line 76 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

cy.get('#reportDefinitionDetailsLink').first().click();

Expand All @@ -83,13 +83,13 @@

cy.url().should('include', 'edit');

cy.wait(1000);

Check failure on line 86 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

cy.get('#reportDefinitionTriggerTypes > div:nth-child(1)').click({ force: true });

Check warning on line 88 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.get('#editReportDefinitionButton').click({ force: true });

Check warning on line 90 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not use force on click and type calls

cy.wait(12500);

Check failure on line 92 in .cypress/integration/02-edit.spec.ts

View workflow job for this annotation

GitHub Actions / Lint

Do not wait for arbitrary time periods

// check that re-direct to home page
cy.get('#reportDefinitionDetailsLink').should('exist');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ interface ReportDefinitionDetails {
created: string;
lastUpdated: string;
source: string;
recordLimit: number | undefined;
timePeriod: string;
fileFormat: string;
status: string | undefined;
Expand All @@ -63,6 +64,7 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a
created: '',
lastUpdated: '',
source: '',
recordLimit: 0,
timePeriod: '',
fileFormat: '',
status: '',
Expand Down Expand Up @@ -417,6 +419,10 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a
created: displayCreatedDate,
lastUpdated: displayUpdatedDate,
source: reportParams.report_source,
recordLimit:
reportParams.report_source != 'Saved search'
? `\u2014`
: reportParams.core_params.limit,
baseUrl: baseUrl,
// TODO: need better display
timePeriod: moment.duration(timeDuration).humanize(),
Expand Down Expand Up @@ -778,6 +784,13 @@ export function ReportDefinitionDetails(props: { match?: any; setBreadcrumbs?: a
)}
reportDetailsComponentContent={sourceURL(reportDefinitionDetails)}
/>
<ReportDetailsComponent
reportDetailsComponentTitle={i18n.translate(
'opensearch.reports.reportDefinitionsDetails.fields.recordLimit',
{ defaultMessage: 'Record limit' }
)}
reportDetailsComponentContent={reportDefinitionDetails.recordLimit}
/>
<ReportDetailsComponent
reportDetailsComponentTitle={i18n.translate(
'opensearch.reports.reportDefinitionsDetails.fields.timePeriod',
Expand Down
15 changes: 15 additions & 0 deletions public/components/main/report_details/report_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ interface ReportDetails {
created: string;
lastUpdated: string;
source: string;
recordLimit: number | undefined;
time_period: string;
defaultFileFormat: string;
state: string | undefined;
Expand Down Expand Up @@ -85,6 +86,7 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl
created: '',
lastUpdated: '',
source: '',
recordLimit: 0,
time_period: '',
defaultFileFormat: '',
state: '',
Expand Down Expand Up @@ -218,6 +220,10 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl
created: convertTimestamp(report.time_created),
lastUpdated: convertTimestamp(report.last_updated),
source: reportParams.report_source,
recordLimit:
reportParams.report_source != 'Saved search'
? `\u2014`
: reportParams.core_params.limit,
// TODO: we have all data needed, time_from, time_to, time_duration,
// think of a way to better display
time_period: (reportParams.report_source !== 'Notebook') ? parseTimePeriod(queryUrl) : `\u2014`,
Expand Down Expand Up @@ -423,6 +429,13 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl
)}
reportDetailsComponentContent={sourceURL(reportDetails)}
/>
<ReportDetailsComponent
reportDetailsComponentTitle={i18n.translate(
'opensearch.reports.reportDefinitionsDetails.fields.recordLimit',
{ defaultMessage: 'Record limit' }
)}
reportDetailsComponentContent={reportDetails.recordLimit}
/>
<ReportDetailsComponent
reportDetailsComponentTitle={i18n.translate(
'opensearch.reports.details.reportSettings.timePeriod',
Expand All @@ -437,6 +450,8 @@ export function ReportDetails(props: { match?: any; setBreadcrumbs?: any; httpCl
)}
reportDetailsComponentContent={fileFormatDownload(reportDetails)}
/>
</EuiFlexGroup>
<EuiFlexGroup>
<ReportDetailsComponent
reportDetailsComponentTitle={i18n.translate(
'opensearch.reports.details.reportSettings.state',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import React, { useEffect, useState } from 'react';
import { i18n } from '@osd/i18n';
import {
EuiFieldText,
EuiFieldNumber,
EuiFlexGroup,
EuiFlexItem,
EuiFormRow,
Expand All @@ -15,13 +16,13 @@ import {
EuiPageContent,
EuiPageContentBody,
EuiHorizontalRule,
EuiText,
EuiSpacer,
EuiRadioGroup,
EuiSelect,
EuiTextArea,
EuiCheckboxGroup,
EuiComboBox,
EuiText,
EuiIcon,
} from '@elastic/eui';
import {
REPORT_SOURCE_RADIOS,
Expand Down Expand Up @@ -83,7 +84,7 @@ export function ReportSettings(props: ReportSettingProps) {
settingsReportSourceErrorMessage,
showTimeRangeError,
showTriggerIntervalNaNError,
showCronError
showCronError,
} = props;

const [reportName, setReportName] = useState('');
Expand All @@ -102,6 +103,7 @@ export function ReportSettings(props: ReportSettingProps) {
[] as any
);
const [savedSearches, setSavedSearches] = useState([] as any);
const [savedSearchRecordLimit, setSavedSearchRecordLimit] = useState(10000);

const [notebooksSourceSelect, setNotebooksSourceSelect] = useState([] as any);
const [notebooks, setNotebooks] = useState([] as any);
Expand Down Expand Up @@ -170,7 +172,7 @@ export function ReportSettings(props: ReportSettingProps) {
reportDefinitionRequest.report_params.core_params.saved_search_id =
savedSearches[0]?.value;
reportDefinitionRequest.report_params.core_params.report_format = 'csv';
reportDefinitionRequest.report_params.core_params.limit = 10000;
reportDefinitionRequest.report_params.core_params.limit = savedSearchRecordLimit;
reportDefinitionRequest.report_params.core_params.excel = true;
} else if (e === 'notebooksReportSource') {
reportDefinitionRequest.report_params.report_source = 'Notebook';
Expand Down Expand Up @@ -235,6 +237,12 @@ export function ReportSettings(props: ReportSettingProps) {
}
};

const handleSavedSearchRecordLimit = (e) => {
setSavedSearchRecordLimit(e.target.value);

reportDefinitionRequest.report_params.core_params.limit = e.target.value;
};

const handleNotebooksSelect = (e) => {
setNotebooksSourceSelect(e);
let fromInContext = false;
Expand Down Expand Up @@ -595,6 +603,13 @@ export function ReportSettings(props: ReportSettingProps) {
reportDefinitionRequest.report_params.report_source = reportSource;
}
});

if (reportSource == REPORT_SOURCE_TYPES.savedSearch) {
setSavedSearchRecordLimit(
response.report_definition.report_params.core_params.limit
);
}

setDefaultFileFormat(
response.report_definition.report_params.core_params.report_format
);
Expand Down Expand Up @@ -669,8 +684,11 @@ export function ReportSettings(props: ReportSettingProps) {
await httpClientProps
.get('../api/observability/notebooks/')
.catch((error: any) => {
console.error('error fetching notebooks, retrying with legacy api', error)
return httpClientProps.get('../api/notebooks/')
console.error(
'error fetching notebooks, retrying with legacy api',
error
);
return httpClientProps.get('../api/notebooks/');
})
.then(async (response: any) => {
let notebooksOptions = getNotebooksOptions(response.data);
Expand Down Expand Up @@ -782,6 +800,30 @@ export function ReportSettings(props: ReportSettingProps) {
/>
</EuiFormRow>
<EuiSpacer />
<EuiFormRow
id="reportSourceSavedSearchRecordLimit"
label={i18n.translate(
'opensearch.reports.reportSettingProps.form.savedSearchRecordLimit',
{ defaultMessage: 'Record limit' }
)}
helpText={
savedSearchRecordLimit > 10000 ? (
<EuiText color="warning" size="xs">
<EuiIcon color="warning" type="alert" size="s" /> Generating
very large reports can cause memory issues.
</EuiText>
) : (
''
)
}
>
<EuiFieldNumber
value={savedSearchRecordLimit}
onChange={handleSavedSearchRecordLimit}
min={1}
/>
</EuiFormRow>
<EuiSpacer />
</div>
) : null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Compatible with OpenSearch and OpenSearch Dashboards Version 2.17.0

### Enhancements
* [Feature] Add the ability to configure record limit/count from the UI ([#395](https://github.com/opensearch-project/dashboards-reporting/pull/395))
* Use smaller and compressed varients of buttons and form components ([#398](https://github.com/opensearch-project/dashboards-reporting/pull/398))
* [Enhancement] De-register reporting when MDS is enabled ([#411](https://github.com/opensearch-project/dashboards-reporting/pull/411))

Expand Down
Loading