From d2cb383f07be3ab5c8f1106465bc6591f1013bb8 Mon Sep 17 00:00:00 2001 From: Akhil S A <109232859+saakhil@users.noreply.github.com> Date: Thu, 22 Aug 2024 18:26:10 +0530 Subject: [PATCH] Cric 1980 add export to review category report (#1845) * CRIC-1980: Add export to review category report Added new API for getting all records --- .../broadinstitute/orsp/UrlMappings.groovy | 1 + .../orsp/api/ReportController.groovy | 6 +++++ .../broadinstitute/orsp/QueryService.groovy | 25 +++++++++++++++++++ src/main/webapp/components/TableComponent.js | 3 ++- .../reviewCategories/ReviewCategories.js | 23 +++++------------ src/main/webapp/util/UrlConstants.js | 1 + src/main/webapp/util/ajax.js | 5 +++- 7 files changed, 45 insertions(+), 19 deletions(-) diff --git a/grails-app/controllers/org/broadinstitute/orsp/UrlMappings.groovy b/grails-app/controllers/org/broadinstitute/orsp/UrlMappings.groovy index 2b98843c6..462fe57aa 100644 --- a/grails-app/controllers/org/broadinstitute/orsp/UrlMappings.groovy +++ b/grails-app/controllers/org/broadinstitute/orsp/UrlMappings.groovy @@ -14,6 +14,7 @@ class UrlMappings { "/api/report/get-funding"(controller: 'report', action: "getFunding", method: 'GET') "/api/report/get-all-fundings"(controller: 'report', action: "getAllFundings", method: 'GET') "/api/report/review-categories"(controller: 'report', action: "findReviewCategories") + "/api/report/get-review-categories"(controller: 'report', action: "getReviewCategories") '/api/swagger/**'(controller: 'api', action: 'swagger') // Compliance report end point diff --git a/grails-app/controllers/org/broadinstitute/orsp/api/ReportController.groovy b/grails-app/controllers/org/broadinstitute/orsp/api/ReportController.groovy index 20836aa86..13cfbb9b5 100644 --- a/grails-app/controllers/org/broadinstitute/orsp/api/ReportController.groovy +++ b/grails-app/controllers/org/broadinstitute/orsp/api/ReportController.groovy @@ -54,6 +54,7 @@ class ReportController extends AuthenticatedController { response.outputStream << content } + // Review category report api with backend pagination def findReviewCategories() { UtilityClass.registerIssueMarshaller(); PaginationParams pagination = new PaginationParams( @@ -68,6 +69,11 @@ class ReportController extends AuthenticatedController { } } + // Review category report api without backend pagination + def getReviewCategories() { + render queryService.getReviewCategoryReport() as JSON + } + def findCollectionLinks() { UtilityClass.registerConsentCollectionReportMarshaller() diff --git a/grails-app/services/org/broadinstitute/orsp/QueryService.groovy b/grails-app/services/org/broadinstitute/orsp/QueryService.groovy index 0bc4dceb5..58116b287 100644 --- a/grails-app/services/org/broadinstitute/orsp/QueryService.groovy +++ b/grails-app/services/org/broadinstitute/orsp/QueryService.groovy @@ -2011,4 +2011,29 @@ class QueryService implements Status { result } + def getReviewCategoryReport() { + SessionFactory sessionFactory = grailsApplication.getMainContext().getBean('sessionFactory') + final session = sessionFactory.currentSession + def query = new StringBuilder() + query.append('select distinct i.id, i.type, i.project_key, i.summary, i.status, i.approval_status, ') + .append('i.reporter, i.request_date, ie.value as review_category from issue i ') + .append('left outer join issue_extra_property ie on ie.project_key = i.project_key and ie.name = "review-category" ') + .append('where i.type = "IRB Project" and i.deleted = 0 order by project_key asc') + final SQLQuery sqlQuery = session.createSQLQuery(query.toString()) + final result = sqlQuery.list().collect {row -> + [ + id: row[0], + type: row[1], + projectKey: row[2], + summary: row[3], + status: row[4], + approvalStatus: row[5], + reporter: row[6], + requestDate: row[7], + reviewCategory: row[8] + ] + } + result + } + } diff --git a/src/main/webapp/components/TableComponent.js b/src/main/webapp/components/TableComponent.js index 1eda2f47c..ffd5a09ea 100644 --- a/src/main/webapp/components/TableComponent.js +++ b/src/main/webapp/components/TableComponent.js @@ -86,7 +86,8 @@ export const TableComponent = hh(class TableComponent extends Component { paginationFactory({ page: this.props.page, totalSize: this.props.totalSize, - sizePerPageList: this.props.sizePerPageList + sizePerPageList: this.props.sizePerPageList, + showTotal: this.props.showTotal }) : null } defaultSorted= { this.props.defaultSorted } diff --git a/src/main/webapp/reviewCategories/ReviewCategories.js b/src/main/webapp/reviewCategories/ReviewCategories.js index 9c942cea9..cbc69ac6d 100644 --- a/src/main/webapp/reviewCategories/ReviewCategories.js +++ b/src/main/webapp/reviewCategories/ReviewCategories.js @@ -140,21 +140,10 @@ const ReviewCategories = hh(class ReviewCategories extends Component { searchValue: search }; this.props.showSpinner(); - Reports.getReviewCategory(query).then(result => { - const lastPage = Math.ceil(result.data.recordsTotal / query.length); + Reports.getReviewCategory().then(result => { if (this._isMounted) { this.setState(prev => { - prev.lastPage = lastPage; - prev.currentPage = page; - prev.categories = result.data.data; - prev.recordsTotal = result.data.recordsTotal; - prev.recordsFiltered = result.data.recordsFiltered; - prev.sizePerPage = query.length; - prev.search = query.searchValue; - prev.sort = { - orderColumn : query.orderColumn, - sortDirection: query.sortDirection - }; + prev.categories = result.data; return prev; }, () => this.props.hideSpinner()) } @@ -232,8 +221,7 @@ const ReviewCategories = hh(class ReviewCategories extends Component { PortalMessage({}), h1({ style: stylesHeader.pageTitle}, ["Review Category Report"]), TableComponent({ - remoteProp: true, - onTableChange: this.onTableChange, + remoteProp: false, data: this.state.categories, columns: columns, keyField: 'projectKey', @@ -243,10 +231,11 @@ const ReviewCategories = hh(class ReviewCategories extends Component { printComments: this.printContent, sizePerPageList: SIZE_PER_PAGE_LIST, page: this.state.currentPage, - totalSize: this.state.recordsFiltered, + totalSize: this.state.categories.length, showExportButtons: true, showSearchBar: true, - pagination: true + pagination: true, + showTotal: true }) ]) ) diff --git a/src/main/webapp/util/UrlConstants.js b/src/main/webapp/util/UrlConstants.js index 3e1af5857..02f555416 100644 --- a/src/main/webapp/util/UrlConstants.js +++ b/src/main/webapp/util/UrlConstants.js @@ -100,6 +100,7 @@ export const UrlConstants = { dataUseRestrictionUrl: context + '/api/data-use/restriction/create', newRestrictionUrl: context + '/api/data-use/new-restriction', reviewCategoriesUrl: context + '/api/report/review-categories', + getReviewCategoriesUrl: context + '/api/report/get-review-categories', qaEventReportUrl: context + '/api/qa-event-report', qaEventReportForProjectUrl: context + '/api/qa-project-event-report', fundingReportsUrl: context + '/api/report/get-funding', diff --git a/src/main/webapp/util/ajax.js b/src/main/webapp/util/ajax.js index f83e80c8f..3b725d6fe 100644 --- a/src/main/webapp/util/ajax.js +++ b/src/main/webapp/util/ajax.js @@ -496,7 +496,7 @@ export const Reports = { } }) }, - getReviewCategory(query) { + findReviewCategory(query) { return axios.get(UrlConstants.reviewCategoriesUrl, { params: { draw: 1, @@ -508,6 +508,9 @@ export const Reports = { } }) }, + getReviewCategory() { + return axios.get(UrlConstants.getReviewCategoriesUrl) + }, getQaEventReport(tab) { return axios.get(UrlConstants.qaEventReportUrl, { params: {