diff --git a/app/client/public/css/styles.css b/app/client/public/css/styles.css index fd3b9e38..260e17ef 100644 --- a/app/client/public/css/styles.css +++ b/app/client/public/css/styles.css @@ -100,6 +100,27 @@ max-height: 90vh; } +.scroll-container { + overflow: auto; /* Ensure the scrollbar is present */ + scrollbar-width: thin; /* For Firefox, make the scrollbar thin */ + scrollbar-color: darkgray; /* Thumb and track colors */ +} + +/* For WebKit browsers */ +.scroll-container::-webkit-scrollbar { + width: 12px; /* Width of the scrollbar */ + height: 12px; /* Height of the scrollbar for horizontal scrolling */ +} + +.scroll-container::-webkit-scrollbar-thumb { + background-color: darkgray; /* Color of the scrollbar thumb */ + border-radius: 6px; /* Round edges */ +} + +.scrollbar { + height: 12px; +} + .sr-only { border: 0; clip: rect(0, 0, 0, 0); diff --git a/app/client/src/components/previewModal.tsx b/app/client/src/components/previewModal.tsx index 5674b5bc..11052f46 100644 --- a/app/client/src/components/previewModal.tsx +++ b/app/client/src/components/previewModal.tsx @@ -181,6 +181,7 @@ export function PreviewModal({ )} { + const topScrollbarRef = useRef(null); + const contentRef = useRef(null); + + const handleScroll = (e: UIEvent) => { + const scrollLeft = e.currentTarget.scrollLeft; + if (contentRef.current) contentRef.current.scrollLeft = scrollLeft; + if (topScrollbarRef.current) + topScrollbarRef.current.scrollLeft = scrollLeft; + }; + // Swap sort direction. const getSortDirection = (prevSortDir: 'ascending' | 'descending') => { if (prevSortDir === 'descending') { @@ -53,102 +63,131 @@ export const Table = ({ } }; + const [width, setWidth] = useState(0); + return ( -
{ - if (node && sortable) { - table.on(node); - } - }} - > -
+
+
+
+
{ + contentRef.current = node; + if (node && sortable) { + table.on(node); + } + }} > -
- - - {columns - .map((obj) => ({ - ...obj, - sortable: obj.sortable !== undefined ? obj.sortable : true, - })) - .map((column: TableColumn, index: number) => ( - - ))} - - - - {data.map((row, i: number) => { - const rowData: TableCell[] = []; - row.forEach((cell: string | number | TableCell) => { - if (sortable) { - rowData.push({ - value: isCellSpec(cell) ? cell.value : cell, - sortValue: isCellSpec(cell) - ? (cell.sortValue ?? cell.value ?? '').toString() - : cell, - }); - } else { - rowData.push({ - value: isCellSpec(cell) ? cell.value : cell, - }); - } - }); - - return ( - - {rowData.map((col, j) => ( - + + + {columns + .map((obj) => ({ + ...obj, + sortable: obj.sortable !== undefined ? obj.sortable : true, + })) + .map((column: TableColumn, index: number) => ( + ))} - - ); - })} - -
handleHeaderClick(index)} - style={{ width: column.width ? `${column.width}px` : 'auto' }} - > - {column.name} -
{ + if (!node) { + setWidth(0); + return; + } + setWidth(node.offsetWidth); + }} + tabIndex={scrollable ? Math.max(0, tabIndex) : tabIndex} + > +
handleHeaderClick(index)} + style={{ + width: column.width ? `${column.width}px` : 'auto', + }} > - {col.value} - + {column.name} +
- {sortable && ( -
- )} + + + + {data.map((row, i: number) => { + const rowData: TableCell[] = []; + row.forEach((cell: string | number | TableCell) => { + if (sortable) { + rowData.push({ + value: isCellSpec(cell) ? cell.value : cell, + sortValue: isCellSpec(cell) + ? (cell.sortValue ?? cell.value ?? '').toString() + : cell, + }); + } else { + rowData.push({ + value: isCellSpec(cell) ? cell.value : cell, + }); + } + }); + + return ( + + {rowData.map((col, j) => ( + + {col.value} + + ))} + + ); + })} + + + {sortable && ( +
+ )} + ); }; diff --git a/app/client/src/routes/home.tsx b/app/client/src/routes/home.tsx index 654e336b..2ff2b5ed 100644 --- a/app/client/src/routes/home.tsx +++ b/app/client/src/routes/home.tsx @@ -561,7 +561,10 @@ function FilterFieldInputs({ ? sourceState[sourceFieldConfig.id] : null; const selectProps = { - additionalOptions: 'additionalOptions' in fieldConfig ? fieldConfig.additionalOptions : [], + additionalOptions: + 'additionalOptions' in fieldConfig + ? fieldConfig.additionalOptions + : [], apiKey, apiUrl, contextFilters: getContextFilters( @@ -709,13 +712,13 @@ function FilterFieldInputs({
{fieldsJsx.map(([field, key, size]) => (
{field} @@ -1501,11 +1504,21 @@ function filterDynamicOptions({ const label = secondaryValue || value; return { label, value }; }); + if (!lastLoadedOption) { + (additionalOptions ?? []) + .concat(defaultOption ? [defaultOption] : []) + .forEach((option) => { + if ( + !inputValue || + (typeof option.label === 'string' && + option.label.toLowerCase().includes(inputValue.toLowerCase())) + ) { + options.unshift(option); + } + }); + } return { - options: - !lastLoadedOption && defaultOption // only include default option in first page - ? [defaultOption, ...additionalOptions, ...options] - : options, + options, hasMore: options.length >= limit, }; }; @@ -1624,8 +1637,10 @@ function getContextFilters( // Returns the default state for inputs function getDefaultFilterState(filterFields: FilterFields) { + const hasParams = + Array.from(new URLSearchParams(window.location.search)).length > 0; return Object.values(filterFields).reduce((a, b) => { - const defaultValue = getDefaultValue(b); + const defaultValue = getDefaultValue(b, !hasParams); const defaultState = defaultValue && isMultiOptionField(b) ? [defaultValue] : defaultValue; return { ...a, [b.key]: defaultState }; @@ -1641,8 +1656,12 @@ function getDefaultSourceState(sourceFields: SourceFields) { }, {}) as SourceFieldState; } -function getDefaultValue(field: FilterField | SourceField) { - const defaultValue = 'default' in field ? field.default : null; +function getDefaultValue( + field: FilterField | SourceField, + useConfiguredDefault = true, +) { + const defaultValue = + useConfiguredDefault && 'default' in field ? field.default : null; return defaultValue ?? (isSingleValueField(field) ? '' : null); } diff --git a/app/cypress/e2e/home.cy.ts b/app/cypress/e2e/home.cy.ts index b3ece441..aac9eb7a 100644 --- a/app/cypress/e2e/home.cy.ts +++ b/app/cypress/e2e/home.cy.ts @@ -17,6 +17,7 @@ describe('Home Page', () => { it('All data profile option are select one by one and check Clear Search button is available ', () => { const profiles = [ + 'Actions Document Search', 'Actions', 'Assessment Units', 'Assessments', @@ -133,7 +134,10 @@ describe('Home Page', () => { 'columns=objectId&columns=region&columns=state&columns=organizationType&columns=organizationId&columns=organizationName&columns=waterType&columns=locationTypeCode&columns=locationText&columns=useClassName&columns=assessmentUnitId&columns=assessmentUnitName&columns=assessmentUnitStatus&columns=reportingCycle&columns=cycleId&columns=locationDescription&columns=sizeSource&columns=sourceScale&columns=waterSize&columns=waterSizeUnits'; const queryValue = `/api/attains/assessmentUnits?${columnsValue}&assessmentUnitStatus=R&state=TX&format=tsv&api_key=`; - cy.selectCopyBox('api-query-copy-box-container', `${serverUrl}${queryValue}`); + cy.selectCopyBox( + 'api-query-copy-box-container', + `${serverUrl}${queryValue}`, + ); cy.findAllByRole('button', { name: 'Clear Search' }).each( ($elem, index) => { @@ -172,4 +176,15 @@ describe('Home Page', () => { cy.findByText('Loading...').should('not.exist'); cy.findByText('No options').should('exist'); }); + + it('Document text search preview window displays with results', () => { + cy.selectProfile('Actions Document Search'); + cy.wait(500); + cy.findByRole('textbox', { + name: 'Search Text / Keyword', + }).type('water'); + cy.findByRole('button', { name: 'Preview' }).click(); + cy.wait(2000); + cy.findByRole('table').should('exist'); + }); }); diff --git a/app/cypress/support/commands.ts b/app/cypress/support/commands.ts index 7b2cc4e0..4c759c41 100644 --- a/app/cypress/support/commands.ts +++ b/app/cypress/support/commands.ts @@ -34,7 +34,11 @@ declare global { * @example cy.dataCy('greeting') */ selectProfile(profile: string): Chainable; - selectOption(id: string, option: string, selectViaKeys?: boolean): Chainable; + selectOption( + id: string, + option: string, + selectViaKeys?: boolean, + ): Chainable; clipboardValue(value: string): Chainable; selectCopyBox(id: string, value: string): Chainable; } @@ -61,24 +65,28 @@ Cypress.Commands.add('selectProfile', (profile: string) => { * @param option - option to select */ -Cypress.Commands.add('selectOption', (id: string, option: string, selectViaKeys: boolean = false) => { - // NOTE: There is a cypress and or react-select bug where the select menu - // does not re-fetch the data when cypress first types something in. - // To work around this I just added a slight delay before typing the - // last character of the provided option. - cy.get(`#${id}`).type(option.slice(0, -1)); - cy.wait(1000); - cy.get(`#${id}`).type(option.slice(-1)); +Cypress.Commands.add( + 'selectOption', + (id: string, option: string, selectViaKeys: boolean = false) => { + // NOTE: There is a cypress and or react-select bug where the select menu + // does not re-fetch the data when cypress first types something in. + // To work around this I just added a slight delay before typing the + // last character of the provided option. + cy.get(`#${id}`).type(option.slice(0, -1)); + cy.wait(1000); + cy.get(`#${id}`).type(option.slice(-1)); - cy.findByText('Loading...').should('not.exist'); - - if(selectViaKeys) { - cy.get(`#${id}`).type('{downArrow}{enter}'); - } else { - cy.get(`#react-select-instance-${id.replace('input-', '')}-option-0`) - .click({ force: true }); + cy.findByText('Loading...').should('not.exist'); + + if (selectViaKeys) { + cy.get(`#${id}`).type('{downArrow}{enter}'); + } else { + cy.get( + `#react-select-instance-${id.replace('input-', '')}-option-0`, + ).click({ force: true }); } -}); + }, +); /** * This read the value from windows clipboard. @@ -102,7 +110,6 @@ Cypress.Commands.add('clipboardValue', (value: string) => { */ Cypress.Commands.add('selectCopyBox', (id: string, value: string) => { - cy.findByTestId(id) - .should('exist') - cy.findByText(value); + cy.findByTestId(id).should('exist'); + cy.findByText(value); }); diff --git a/app/server/app/content/config/fields.json b/app/server/app/content/config/fields.json index baf8a1b8..1b4e37b4 100644 --- a/app/server/app/content/config/fields.json +++ b/app/server/app/content/config/fields.json @@ -398,9 +398,7 @@ "key": "reportingCycle", "label": "Reporting Cycle", "type": "select", - "additionalOptions": [ - { "value": -1, "label": "Any" } - ], + "additionalOptions": [{ "value": -1, "label": "Any" }], "default": { "value": "", "label": "Latest" }, "direction": "desc", "contextFields": ["organizationId", "region", "state"] diff --git a/app/server/app/content/swagger/api-private.json b/app/server/app/content/swagger/api-private.json index 9c91a02a..dd5ecdaf 100644 --- a/app/server/app/content/swagger/api-private.json +++ b/app/server/app/content/swagger/api-private.json @@ -618,7 +618,7 @@ "description": "The column name for which values are queried.", "in": "path", "required": true, - "example": "assessmentUnitId", + "example": "state", "schema": { "type": "string" } @@ -636,7 +636,7 @@ "filters": { "objectId": [42] }, - "additionalColumns": ["assessmentUnitId"] + "additionalColumns": ["state"] }, "properties": { "text": { diff --git a/app/server/app/content/swagger/api-public-EPA-SCAN.json b/app/server/app/content/swagger/api-public-EPA-SCAN.json index af41f7f0..68c4ccd1 100644 --- a/app/server/app/content/swagger/api-public-EPA-SCAN.json +++ b/app/server/app/content/swagger/api-public-EPA-SCAN.json @@ -34,6 +34,232 @@ } }, "paths": { + "/attains/actionDocuments": { + "get": { + "tags": ["ATTAINS - Action Documents"], + "summary": "Query Action Documents profile data", + "description": "Query the Action Documents profile on the ATTAINS Query page.", + "parameters": [ + { + "$ref": "#/components/parameters/apiKeyHeader" + }, + { + "$ref": "#/components/parameters/outputFormatParam" + }, + { + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" + }, + { + "$ref": "#/components/parameters/columnsParam" + }, + { + "$ref": "#/components/parameters/objectIdParam" + }, + { + "$ref": "#/components/parameters/actionDocumentTypeParam" + }, + { + "$ref": "#/components/parameters/actionDocumentUrlParam" + }, + { + "$ref": "#/components/parameters/actionIdParam" + }, + { + "$ref": "#/components/parameters/actionNameParam" + }, + { + "$ref": "#/components/parameters/actionTypeParam" + }, + { + "$ref": "#/components/parameters/completionDateLoParam" + }, + { + "$ref": "#/components/parameters/completionDateHiParam" + }, + { + "$ref": "#/components/parameters/documentFileNameParam" + }, + { + "$ref": "#/components/parameters/documentFileTypeNameParam" + }, + { + "$ref": "#/components/parameters/documentKeyParam" + }, + { + "$ref": "#/components/parameters/documentNameParam" + }, + { + "$ref": "#/components/parameters/documentQueryParam" + }, + { + "$ref": "#/components/parameters/organizationIdParam" + }, + { + "$ref": "#/components/parameters/organizationNameParam" + }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, + { + "$ref": "#/components/parameters/regionParam" + }, + { + "$ref": "#/components/parameters/stateParam" + }, + { + "$ref": "#/components/parameters/tmdlDateLoParam" + }, + { + "$ref": "#/components/parameters/tmdlDateHiParam" + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/ActionDocumentsQuerySuccess" + }, + "400": { + "$ref": "#/components/responses/InvalidRequestError" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + } + }, + "post": { + "tags": ["ATTAINS - Action Documents"], + "summary": "Query Action Documents profile data", + "description": "Query the Action Documents profile on the ATTAINS Query page.", + "parameters": [ + { + "$ref": "#/components/parameters/apiKeyHeader" + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/ActionDocumentsQueryRequestBody" + }, + "responses": { + "200": { + "$ref": "#/components/responses/ActionDocumentsQuerySuccess" + }, + "400": { + "$ref": "#/components/responses/InvalidRequestError" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + } + } + }, + "/attains/actionDocuments/count": { + "get": { + "summary": "Row count of Action Documents profile query", + "description": "Query the Action Documents profile on the ATTAINS Query page.", + "tags": ["ATTAINS - Action Documents"], + "parameters": [ + { + "$ref": "#/components/parameters/apiKeyHeader" + }, + { + "$ref": "#/components/parameters/objectIdParam" + }, + { + "$ref": "#/components/parameters/actionDocumentTypeParam" + }, + { + "$ref": "#/components/parameters/actionDocumentUrlParam" + }, + { + "$ref": "#/components/parameters/actionIdParam" + }, + { + "$ref": "#/components/parameters/actionNameParam" + }, + { + "$ref": "#/components/parameters/actionTypeParam" + }, + { + "$ref": "#/components/parameters/completionDateLoParam" + }, + { + "$ref": "#/components/parameters/completionDateHiParam" + }, + { + "$ref": "#/components/parameters/documentFileNameParam" + }, + { + "$ref": "#/components/parameters/documentFileTypeNameParam" + }, + { + "$ref": "#/components/parameters/documentKeyParam" + }, + { + "$ref": "#/components/parameters/documentNameParam" + }, + { + "$ref": "#/components/parameters/documentQueryParam" + }, + { + "$ref": "#/components/parameters/organizationIdParam" + }, + { + "$ref": "#/components/parameters/organizationNameParam" + }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, + { + "$ref": "#/components/parameters/regionParam" + }, + { + "$ref": "#/components/parameters/stateParam" + }, + { + "$ref": "#/components/parameters/tmdlDateLoParam" + }, + { + "$ref": "#/components/parameters/tmdlDateHiParam" + } + ], + "responses": { + "200": { + "$ref": "#/components/responses/QueryCountSuccess" + }, + "400": { + "$ref": "#/components/responses/InvalidRequestError" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + } + }, + "post": { + "summary": "Row count of Action Documents profile query", + "description": "Query the Action Documents profile on the ATTAINS Query page.", + "tags": ["ATTAINS - Action Documents"], + "parameters": [ + { + "$ref": "#/components/parameters/apiKeyHeader" + } + ], + "requestBody": { + "$ref": "#/components/requestBodies/ActionDocumentsCountRequestBody" + }, + "responses": { + "200": { + "$ref": "#/components/responses/QueryCountSuccess" + }, + "400": { + "$ref": "#/components/responses/InvalidRequestError" + }, + "500": { + "$ref": "#/components/responses/ServerError" + } + } + } + }, "/attains/actions": { "get": { "tags": ["ATTAINS - Actions"], @@ -47,7 +273,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -97,6 +326,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/parameterParam" }, @@ -204,6 +436,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/parameterParam" }, @@ -270,7 +505,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -383,6 +621,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/overallStatusParam" }, @@ -604,6 +845,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/overallStatusParam" }, @@ -721,7 +965,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -753,6 +1000,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/regionParam" }, @@ -842,6 +1092,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/regionParam" }, @@ -908,7 +1161,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -940,6 +1196,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/regionParam" }, @@ -1029,6 +1288,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/regionParam" }, @@ -1095,7 +1357,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -1121,6 +1386,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/regionParam" }, @@ -1198,6 +1466,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/regionParam" }, @@ -1258,7 +1529,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -1290,6 +1564,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/overallStatusParam" }, @@ -1388,6 +1665,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/overallStatusParam" }, @@ -1463,7 +1743,10 @@ "$ref": "#/components/parameters/outputFormatParam" }, { - "$ref": "#/components/parameters/startIdParam" + "$ref": "#/components/parameters/pageNumberParam" + }, + { + "$ref": "#/components/parameters/pageSizeParam" }, { "$ref": "#/components/parameters/columnsParam" @@ -1525,6 +1808,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/otherIdentifierParam" }, @@ -1656,6 +1942,9 @@ { "$ref": "#/components/parameters/organizationNameParam" }, + { + "$ref": "#/components/parameters/organizationTypeParam" + }, { "$ref": "#/components/parameters/otherIdentifierParam" }, @@ -1744,16 +2033,206 @@ "500": { "$ref": "#/components/responses/ServerError" } - } - } - } - }, - "externalDocs": { - "description": "Find out more about Expert Query", - "url": "" - }, - "components": { - "schemas": { + } + } + } + }, + "externalDocs": { + "description": "Find out more about Expert Query", + "url": "" + }, + "components": { + "schemas": { + "ActionDocumentsFilters": { + "type": "object", + "properties": { + "objectId": { + "type": "array", + "items": { + "type": "integer" + } + }, + "actionDocumentType": { + "type": "array", + "items": { + "type": "string" + } + }, + "actionDocumentUrl": { + "type": "array", + "items": { + "type": "string" + } + }, + "actionId": { + "type": "array", + "items": { + "type": "string" + } + }, + "actionName": { + "type": "array", + "items": { + "type": "string" + } + }, + "actionType": { + "type": "array", + "items": { + "type": "string" + } + }, + "completionDateLo": { + "type": "string", + "format": "date" + }, + "completionDateHi": { + "type": "string", + "format": "date" + }, + "documentFileName": { + "type": "array", + "items": { + "type": "string" + } + }, + "documentFileTypeName": { + "type": "array", + "items": { + "type": "string" + } + }, + "documentKey": { + "type": "array", + "items": { + "type": "integer" + } + }, + "documentName": { + "type": "array", + "items": { + "type": "string" + } + }, + "documentQuery": { + "type": "string" + }, + "organizationId": { + "type": "array", + "items": { + "type": "string" + } + }, + "organizationName": { + "type": "array", + "items": { + "type": "string" + } + }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, + "region": { + "type": "array", + "items": { + "type": "string" + } + }, + "state": { + "type": "array", + "items": { + "type": "string" + } + }, + "tmdlDateLo": { + "type": "string", + "format": "date" + }, + "tmdlDateHi": { + "type": "string", + "format": "date" + } + } + }, + "ActionDocumentsQueryOutput": { + "type": "object", + "properties": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { + "type": "integer" + }, + "data": { + "type": "array", + "items": { + "type": "object", + "properties": { + "objectId": { + "type": "integer" + }, + "actionDocumentType": { + "type": "string" + }, + "actionDocumentUrl": { + "type": "string" + }, + "actionId": { + "type": "string" + }, + "actionName": { + "type": "string" + }, + "actionType": { + "type": "string" + }, + "completionDate": { + "type": "string", + "format": "date" + }, + "documentDesc": { + "type": "string" + }, + "documentFileName": { + "type": "string" + }, + "documentFileTypeName": { + "type": "string" + }, + "documentKey": { + "type": "integer" + }, + "documentName": { + "type": "string" + }, + "organizationId": { + "type": "string" + }, + "organizationName": { + "type": "string" + }, + "organizationType": { + "type": "string" + }, + "region": { + "type": "string" + }, + "state": { + "type": "string" + }, + "tmdlDate": { + "type": "string", + "format": "date" + } + } + } + } + }, + "required": ["data", "pageNumber", "pageSize"] + }, "ActionsFilters": { "type": "object", "properties": { @@ -1837,6 +2316,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "parameter": { "type": "array", "items": { @@ -1872,7 +2357,10 @@ "ActionsQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -1955,7 +2443,7 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] }, "AssessmentsFilters": { "type": "object", @@ -2134,6 +2622,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "overallStatus": { "type": "array", "items": { @@ -2272,7 +2766,10 @@ "AssessmentsQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -2456,7 +2953,7 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] }, "AssessmentUnitsFilters": { "type": "object", @@ -2515,6 +3012,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "region": { "type": "array", "items": { @@ -2601,6 +3104,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "region": { "type": "array", "items": { @@ -2633,7 +3142,10 @@ "AssessmentUnitsQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -2706,12 +3218,15 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] }, "AssessmentUnitsMonitoringLocationsQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -2787,7 +3302,7 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] }, "CatchmentCorrespondenceFilters": { "type": "object", @@ -2834,6 +3349,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "region": { "type": "array", "items": { @@ -2854,7 +3375,10 @@ "CatchmentCorrespondenceQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -2899,7 +3423,7 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] }, "FileAttachmentCsv": { "type": "string", @@ -2917,7 +3441,10 @@ "Options": { "type": "object", "properties": { - "startId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "format": { @@ -2997,6 +3524,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "overallStatus": { "type": "array", "items": { @@ -3047,7 +3580,10 @@ "SourcesQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -3123,7 +3659,7 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] }, "TmdlFilters": { "type": "object", @@ -3232,6 +3768,12 @@ "type": "string" } }, + "organizationType": { + "type": "array", + "items": { + "type": "string" + } + }, "otherIdentifier": { "type": "array", "items": { @@ -3287,7 +3829,10 @@ "TmdlQueryOutput": { "type": "object", "properties": { - "nextId": { + "pageNumber": { + "type": "integer" + }, + "pageSize": { "type": "integer" }, "data": { @@ -3406,15 +3951,39 @@ } } }, - "required": ["data"] + "required": ["data", "pageNumber", "pageSize"] } }, "parameters": { "actionAgencyParam": { "name": "actionAgency", "in": "query", - "example": ["State"], + "example": "State", + "explode": true, + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "actionDocumentTypeParam": { + "name": "actionDocumentType", + "in": "query", + "explode": true, + "example": "TMDL Report", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "actionDocumentUrlParam": { + "name": "actionDocumentUrl", + "in": "query", "explode": true, + "example": "https://attains.epa.gov/attains-public/api/documents/actions/21MSWQ/22502/102354", "schema": { "type": "array", "items": { @@ -3426,7 +3995,7 @@ "name": "actionId", "in": "query", "explode": true, - "example": ["64808"], + "example": "64808", "schema": { "type": "array", "items": { @@ -3438,7 +4007,7 @@ "name": "actionName", "in": "query", "explode": true, - "example": ["12-Mile Creek"], + "example": "12-Mile Creek", "schema": { "type": "array", "items": { @@ -3450,7 +4019,7 @@ "name": "actionType", "in": "query", "explode": true, - "example": ["Implementation Completed"], + "example": "Implementation Completed", "schema": { "type": "array", "items": { @@ -3462,7 +4031,7 @@ "name": "addressedParameterGroup", "in": "query", "explode": true, - "example": ["AMMONIA"], + "example": "AMMONIA", "schema": { "type": "array", "items": { @@ -3474,7 +4043,7 @@ "name": "addressedParameter", "in": "query", "explode": true, - "example": ["AMMONIA"], + "example": "AMMONIA", "schema": { "type": "array", "items": { @@ -3486,7 +4055,7 @@ "name": "alternateListingIdentifier", "in": "query", "explode": true, - "example": ["SD-CH-L-SHERIDAN_01"], + "example": "SD-CH-L-SHERIDAN_01", "schema": { "type": "array", "items": { @@ -3508,7 +4077,7 @@ "name": "assessmentBasis", "in": "query", "explode": true, - "example": ["Monitored Data"], + "example": "Monitored Data", "schema": { "type": "array", "items": { @@ -3538,7 +4107,7 @@ "name": "assessmentMethods", "in": "query", "explode": true, - "example": ["2002 Assessment Methodology"], + "example": "2002 Assessment Methodology", "schema": { "type": "array", "items": { @@ -3550,7 +4119,7 @@ "name": "assessmentTypes", "in": "query", "explode": true, - "example": ["PHYSICAL/CHEMICAL"], + "example": "PHYSICAL/CHEMICAL", "schema": { "type": "array", "items": { @@ -3562,7 +4131,7 @@ "name": "assessmentUnitId", "in": "query", "explode": true, - "example": ["AZ150200001-010_00"], + "example": "AZ150200001-010_00", "schema": { "type": "array", "items": { @@ -3574,7 +4143,7 @@ "name": "assessmentUnitName", "in": "query", "explode": true, - "example": ["Abbott Branch"], + "example": "Abbott Branch", "schema": { "type": "array", "items": { @@ -3586,7 +4155,7 @@ "name": "assessmentUnitStatus", "in": "query", "explode": true, - "example": ["A"], + "example": "A", "schema": { "type": "array", "items": { @@ -3598,7 +4167,7 @@ "name": "associatedActionAgency", "in": "query", "explode": true, - "example": ["State"], + "example": "State", "schema": { "type": "array", "items": { @@ -3610,7 +4179,7 @@ "name": "associatedActionId", "in": "query", "explode": true, - "example": ["64808"], + "example": "64808", "schema": { "type": "array", "items": { @@ -3622,7 +4191,7 @@ "name": "associatedActionName", "in": "query", "explode": true, - "example": ["12-Mile Creek"], + "example": "12-Mile Creek", "schema": { "type": "array", "items": { @@ -3634,7 +4203,7 @@ "name": "associatedActionStatus", "in": "query", "explode": true, - "example": ["EPA Final Action"], + "example": "EPA Final Action", "schema": { "type": "array", "items": { @@ -3646,7 +4215,7 @@ "name": "associatedActionType", "in": "query", "explode": true, - "example": ["Implementation Completed"], + "example": "Implementation Completed", "schema": { "type": "array", "items": { @@ -3658,7 +4227,7 @@ "name": "causeName", "in": "query", "explode": true, - "example": ["EUTROPHICATION"], + "example": "EUTROPHICATION", "schema": { "type": "array", "items": { @@ -3671,7 +4240,7 @@ "description": "The columns to return in the result set, and the order in which to return them.", "in": "query", "explode": true, - "example": ["assessmentUnitId", "assessmentUnitName"], + "example": "assessmentUnitId", "schema": { "type": "array", "items": { @@ -3701,7 +4270,7 @@ "name": "confirmed", "in": "query", "explode": true, - "example": ["Y"], + "example": "Y", "schema": { "type": "array", "items": { @@ -3729,7 +4298,7 @@ "name": "cwa303dPriorityRanking", "in": "query", "explode": true, - "example": ["High"], + "example": "High", "schema": { "type": "array", "items": { @@ -3775,7 +4344,10 @@ "explode": true, "example": -504164, "schema": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "cycleIdParam": { @@ -3784,7 +4356,10 @@ "explode": true, "example": 2346, "schema": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "cycleLastAssessedLoParam": { @@ -3823,7 +4398,7 @@ "name": "delisted", "in": "query", "explode": true, - "example": ["Y"], + "example": "Y", "schema": { "type": "array", "items": { @@ -3835,7 +4410,55 @@ "name": "delistedReason", "in": "query", "explode": true, - "example": ["Not specified"], + "example": "Not specified", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "documentFileNameParam": { + "name": "documentFileName", + "in": "query", + "explode": true, + "example": "54524_Hatchie_North Indpendent ph TMDL final.pdf", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "documentFileTypeNameParam": { + "name": "documentFileTypeName", + "in": "query", + "explode": true, + "example": "application/pdf", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "documentKeyParam": { + "name": "documentKey", + "in": "query", + "explode": true, + "example": 102600, + "schema": { + "type": "array", + "items": { + "type": "integer" + } + } + }, + "documentNameParam": { + "name": "documentName", + "in": "query", + "explode": true, + "example": "North Indpendent ph TMDL final ERRATA", "schema": { "type": "array", "items": { @@ -3843,11 +4466,19 @@ } } }, + "documentQueryParam": { + "name": "documentQuery", + "in": "query", + "example": "Tuscumbia River Canal", + "schema": { + "type": "string" + } + }, "epaIrCategoryParam": { "name": "epaIrCategory", "in": "query", "explode": true, - "example": ["4A"], + "example": "4A", "schema": { "type": "array", "items": { @@ -3859,7 +4490,7 @@ "name": "explicitMarginOfSafety", "in": "query", "explode": true, - "example": ["10%"], + "example": "10%", "schema": { "type": "array", "items": { @@ -3870,7 +4501,7 @@ "fiscalYearEstablishedLoParam": { "name": "fiscalYearEstablishedLo", "in": "query", - "example": ["1994"], + "example": "1994", "schema": { "type": "string" } @@ -3878,7 +4509,7 @@ "fiscalYearEstablishedHiParam": { "name": "fiscalYearEstablishedHi", "in": "query", - "example": ["2002"], + "example": "2002", "schema": { "type": "string" } @@ -3887,7 +4518,7 @@ "name": "implicitMarginOfSafety", "in": "query", "explode": true, - "example": ["conservative assumptions"], + "example": "conservative assumptions", "schema": { "type": "array", "items": { @@ -3899,7 +4530,7 @@ "name": "includeInMeasure", "in": "query", "explode": true, - "example": ["Y"], + "example": "Y", "schema": { "type": "array", "items": { @@ -3911,7 +4542,7 @@ "name": "inIndianCountry", "in": "query", "explode": true, - "example": ["N"], + "example": "N", "schema": { "type": "array", "items": { @@ -3923,7 +4554,7 @@ "name": "locationText", "in": "query", "explode": true, - "example": ["01010001"], + "example": "01010001", "schema": { "type": "array", "items": { @@ -3935,7 +4566,7 @@ "name": "locationTypeCode", "in": "query", "explode": true, - "example": ["Basin"], + "example": "Basin", "schema": { "type": "array", "items": { @@ -3987,7 +4618,7 @@ "name": "monitoringLocationId", "in": "query", "explode": true, - "example": ["1083"], + "example": "1083", "schema": { "type": "array", "items": { @@ -3999,7 +4630,7 @@ "name": "monitoringLocationOrgId", "in": "query", "explode": true, - "example": ["21AWIC"], + "example": "21AWIC", "schema": { "type": "array", "items": { @@ -4011,7 +4642,7 @@ "name": "npdesIdentifier", "in": "query", "explode": true, - "example": ["KS0099571"], + "example": "KS0099571", "schema": { "type": "array", "items": { @@ -4026,14 +4657,17 @@ "explode": true, "example": 42, "schema": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "organizationIdParam": { "name": "organizationId", "in": "query", "explode": true, - "example": ["21AWIC"], + "example": "21AWIC", "schema": { "type": "array", "items": { @@ -4045,7 +4679,19 @@ "name": "organizationName", "in": "query", "explode": true, - "example": ["Georgia Environmental Protection Division"], + "example": "Georgia Environmental Protection Division", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + "organizationTypeParam": { + "name": "organizationType", + "in": "query", + "explode": true, + "example": "State", "schema": { "type": "array", "items": { @@ -4067,7 +4713,7 @@ "name": "otherIdentifier", "in": "query", "explode": true, - "example": ["City of Wellington"], + "example": "City of Wellington", "schema": { "type": "array", "items": { @@ -4079,7 +4725,7 @@ "name": "overallStatus", "in": "query", "explode": true, - "example": ["Fully Supporting"], + "example": "Fully Supporting", "schema": { "type": "array", "items": { @@ -4087,11 +4733,27 @@ } } }, + "pageNumberParam": { + "name": "pageNumber", + "in": "query", + "example": 2, + "schema": { + "type": "integer" + } + }, + "pageSizeParam": { + "name": "pageSize", + "in": "query", + "example": 20, + "schema": { + "type": "integer" + } + }, "parameterAttainmentParam": { "name": "parameterAttainment", "in": "query", "explode": true, - "example": ["1,2-DICHLOROBENZENE"], + "example": "1,2-DICHLOROBENZENE", "schema": { "type": "array", "items": { @@ -4103,7 +4765,7 @@ "name": "parameterGroup", "in": "query", "explode": true, - "example": ["BIOTOXINS"], + "example": "BIOTOXINS", "schema": { "type": "array", "items": { @@ -4115,7 +4777,7 @@ "name": "parameterIrCategory", "in": "query", "explode": true, - "example": ["4A"], + "example": "4A", "schema": { "type": "array", "items": { @@ -4127,7 +4789,7 @@ "name": "parameterName", "in": "query", "explode": true, - "example": ["EUTROPHICATION"], + "example": "EUTROPHICATION", "schema": { "type": "array", "items": { @@ -4139,7 +4801,7 @@ "name": "parameter", "in": "query", "explode": true, - "example": ["EUTROPHICATION"], + "example": "EUTROPHICATION", "schema": { "type": "array", "items": { @@ -4151,7 +4813,7 @@ "name": "parameterStateIrCategory", "in": "query", "explode": true, - "example": ["5"], + "example": "5", "schema": { "type": "array", "items": { @@ -4163,7 +4825,7 @@ "name": "parameterStatus", "in": "query", "explode": true, - "example": ["Observed effect"], + "example": "Observed effect", "schema": { "type": "array", "items": { @@ -4175,7 +4837,7 @@ "name": "pollutantGroup", "in": "query", "explode": true, - "example": ["AMMONIA"], + "example": "AMMONIA", "schema": { "type": "array", "items": { @@ -4187,7 +4849,7 @@ "name": "pollutant", "in": "query", "explode": true, - "example": ["ACID"], + "example": "ACID", "schema": { "type": "array", "items": { @@ -4199,7 +4861,7 @@ "name": "pollutantIndicator", "in": "query", "explode": true, - "example": ["Y"], + "example": "Y", "schema": { "type": "array", "items": { @@ -4211,7 +4873,7 @@ "name": "region", "in": "query", "explode": true, - "example": ["01"], + "example": "01", "schema": { "type": "array", "items": { @@ -4224,8 +4886,12 @@ "in": "query", "example": 2020, "explode": true, + "description": "Filter the summary to a specific reporting cycle in terms of the four-digit year the reporting cycle ended (e.g., for the 4/2/2016 – 3/31/2018 reporting cycle, the four-digit reporting cycle is “2018”). If left blank, the service will return the most recent cycle. If -1 is used, the service will return all reporting cycles.", "schema": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "seasonEndDateLoParam": { @@ -4268,7 +4934,7 @@ "name": "sourceName", "in": "query", "explode": true, - "example": ["ACID MINE DRAINAGE"], + "example": "ACID MINE DRAINAGE", "schema": { "type": "array", "items": { @@ -4280,7 +4946,7 @@ "name": "sourceType", "in": "query", "explode": true, - "example": ["Nonpoint source"], + "example": "Nonpoint source", "schema": { "type": "array", "items": { @@ -4288,19 +4954,11 @@ } } }, - "startIdParam": { - "name": "startId", - "in": "query", - "example": 20, - "schema": { - "type": "integer" - } - }, "stateIrCategoryParam": { "name": "stateIrCategory", "in": "query", "explode": true, - "example": ["4A"], + "example": "4A", "schema": { "type": "array", "items": { @@ -4312,7 +4970,7 @@ "name": "state", "in": "query", "explode": true, - "example": ["OH"], + "example": "OH", "schema": { "type": "array", "items": { @@ -4350,7 +5008,7 @@ "name": "useClassName", "in": "query", "explode": true, - "example": ["CLASS B"], + "example": "CLASS B", "schema": { "type": "array", "items": { @@ -4362,7 +5020,7 @@ "name": "useGroup", "in": "query", "explode": true, - "example": ["AGRICULTURAL"], + "example": "AGRICULTURAL", "schema": { "type": "array", "items": { @@ -4374,7 +5032,7 @@ "name": "useIrCategory", "in": "query", "explode": true, - "example": ["4A"], + "example": "4A", "schema": { "type": "array", "items": { @@ -4386,7 +5044,7 @@ "name": "useName", "in": "query", "explode": true, - "example": ["Aquaculture"], + "example": "Aquaculture", "schema": { "type": "array", "items": { @@ -4398,7 +5056,7 @@ "name": "useStateIrCategory", "in": "query", "explode": true, - "example": ["5"], + "example": "5", "schema": { "type": "array", "items": { @@ -4410,7 +5068,7 @@ "name": "useSupport", "in": "query", "explode": true, - "example": ["Fully Supporting"], + "example": "Fully Supporting", "schema": { "type": "array", "items": { @@ -4422,7 +5080,7 @@ "name": "vision303dPriority", "in": "query", "explode": true, - "example": ["Y"], + "example": "Y", "schema": { "type": "array", "items": { @@ -4434,7 +5092,7 @@ "name": "wasteLoadAllocation", "in": "query", "explode": true, - "example": [7.09], + "example": 7.09, "schema": { "type": "array", "items": { @@ -4447,7 +5105,7 @@ "name": "waterType", "in": "query", "explode": true, - "example": ["ESTUARY"], + "example": "ESTUARY", "schema": { "type": "array", "items": { @@ -4457,6 +5115,45 @@ } }, "requestBodies": { + "ActionDocumentsCountRequestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "filters": { + "$ref": "#/components/schemas/ActionDocumentsFilters" + } + } + } + } + }, + "required": true + }, + "ActionDocumentsQueryRequestBody": { + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "options": { + "$ref": "#/components/schemas/Options" + }, + "columns": { + "type": "array", + "items": { + "type": "string" + } + }, + "filters": { + "$ref": "#/components/schemas/ActionDocumentsFilters" + } + } + } + } + }, + "required": true + }, "ActionsCountRequestBody": { "content": { "application/json": { @@ -4732,6 +5429,59 @@ } }, "responses": { + "ActionDocumentsQuerySuccess": { + "description": "The query executed successfully. The response contains the query results or a message indicating that the maximum query size was exceeded.", + "content": { + "application/json": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/ActionDocumentsQueryOutput" + }, + { + "$ref": "#/components/schemas/QuerySizeExceededMessage" + } + ] + } + }, + "application/octet-stream": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/FileAttachmentXlsx" + }, + { + "$ref": "#/components/schemas/QuerySizeExceededMessage" + } + ] + } + }, + "text/csv": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/FileAttachmentCsv" + }, + { + "$ref": "#/components/schemas/QuerySizeExceededMessage" + } + ] + } + }, + "text/tsv": { + "schema": { + "oneOf": [ + { + "$ref": "#/components/schemas/FileAttachmentTsv" + }, + { + "$ref": "#/components/schemas/QuerySizeExceededMessage" + } + ] + } + } + } + }, "ActionsQuerySuccess": { "description": "The query executed successfully. The response contains the query results or a message indicating that the maximum query size was exceeded.", "content": { diff --git a/app/server/app/content/swagger/api-public.json b/app/server/app/content/swagger/api-public.json index b26a77c0..b6693939 100644 --- a/app/server/app/content/swagger/api-public.json +++ b/app/server/app/content/swagger/api-public.json @@ -4890,7 +4890,10 @@ "explode": true, "description": "Filter the summary to a specific reporting cycle in terms of the four-digit year the reporting cycle ended (e.g., for the 4/2/2016 – 3/31/2018 reporting cycle, the four-digit reporting cycle is “2018”). If left blank, the service will return the most recent cycle. If -1 is used, the service will return all reporting cycles.", "schema": { - "type": "integer" + "type": "array", + "items": { + "type": "integer" + } } }, "seasonEndDateLoParam": { diff --git a/app/server/app/routes/attains.js b/app/server/app/routes/attains.js index 34d11002..4f116d27 100644 --- a/app/server/app/routes/attains.js +++ b/app/server/app/routes/attains.js @@ -409,7 +409,7 @@ function parseCriteria(req, query, profile, queryParams, countOnly = false) { } } -function parseDocumentSearchCriteria(req, query, profile, queryParams) { +function parseDocumentSearchCriteria(req, res, query, profile, queryParams) { const columnsForFilter = Object.keys(queryParams.filters); let columnsToReturn = queryParams.columns ?? []; const view = findView(profile, columnsForFilter.concat(columnsToReturn)); @@ -419,6 +419,11 @@ function parseDocumentSearchCriteria(req, query, profile, queryParams) { const documentQueryColumn = target.columns.find( (col) => col.type === 'tsvector', ); + if (!documentQueryColumn) { + return res.status(200).json({ + message: `No results found for the current query. Please refine the search.`, + }); + } const documentQuery = queryParams.filters[documentQueryColumn.alias]; const isDocumentSearch = documentQueryColumn && columnsForFilter.includes(documentQueryColumn.alias); @@ -512,7 +517,7 @@ async function executeQuery(profile, req, res) { // TODO: Merge this into one function. if (profile.id === 'actionDocuments') { - parseDocumentSearchCriteria(req, query, profile, queryParams); + parseDocumentSearchCriteria(req, res, query, profile, queryParams); } else { parseCriteria(req, query, profile, queryParams); } @@ -665,7 +670,7 @@ async function executeQueryCountOnly(profile, req, res) { // TODO: Merge this into one function. if (profile.id === 'actionDocuments') { - parseDocumentSearchCriteria(req, query, profile, queryParams); + parseDocumentSearchCriteria(req, res, query, profile, queryParams); } else { parseCriteria(req, query, profile, queryParams, true); } @@ -753,19 +758,13 @@ async function executeValuesQuery(profile, req, res) { } let values; - try { - values = await queryColumnValues( - res, - profile, - columns, - params, - req.activeSchema, - ); - } catch (err) { - return res.status(400).json({ - message: err.message, - }); - } + values = await queryColumnValues( + res, + profile, + columns, + params, + req.activeSchema, + ); return res.status(200).json(values); } catch (error) { log.error( diff --git a/app/server/tests/api.attains.test.js b/app/server/tests/api.attains.test.js index d16b1493..c587d613 100644 --- a/app/server/tests/api.attains.test.js +++ b/app/server/tests/api.attains.test.js @@ -158,7 +158,7 @@ describe('API Attains Tests', () => { .expect('Content-Type', /json/); expect(response.body).toEqual({ - message: 'The requested profile does not exist', + message: 'The api route does not exist.', }); }); @@ -327,7 +327,8 @@ describe('API Attains Tests', () => { }); test('POST /api/attains/assessments limit exceeded exception', async () => { - const body = { text: '', limit: 120 }; + const limit = 520; + const body = { text: '', limit }; const response = await supertest(app) .post(`/api/attains/assessments/values/assessmentUnitId`) .send(body) @@ -335,8 +336,7 @@ describe('API Attains Tests', () => { .expect('Content-Type', /json/); expect(response.body).toEqual({ - error: - 'Error: The provided limit (120) exceeds the maximum 100 allowable limit.', + error: `Error: The provided limit (${limit}) exceeds the maximum 500 allowable limit.`, }); }); @@ -397,4 +397,15 @@ describe('API Attains Tests', () => { expect(Array.isArray(response.body)).toBe(true); }); + + test('GET /api/attains/actionDocuments query returns ranked results', async () => { + const response = await supertest(app) + .get( + '/api/attains/actionDocuments?columns=objectId&documentQuery=test&limit=10', + ) + .expect(200); + + expect(Array.isArray(response.body.data)).toBe(true); + expect(response.body.data.pop()).toHaveProperty('rankPercent'); + }); });