-
Notifications
You must be signed in to change notification settings - Fork 236
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
REPORT-906: Add pagination support to ReportRequest read methods #249
Conversation
* @return {@link ReportRequestDTO} object which contains report requests and total count data | ||
*/ | ||
@Transactional(readOnly = true) | ||
ReportRequestDTO getReportsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add the since annotation? https://wiki.openmrs.org/display/docs/Java+Conventions#JavaConventions-NewPublicMethodsandClasses
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the new method name, does it mean we already have a getReports
method without pagination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two getReportRequests
methods without pagination, both return a List
.
The getReportsWithPagination
returns 'wrapper' object - a reason for different name.
We'll change the name to getReportRequestsWithPagination
as suggested in some of the later comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Annotation added, method name changed.
@@ -140,6 +141,12 @@ public interface ReportService extends OpenmrsService { | |||
@Transactional(readOnly = true) | |||
public List<ReportRequest> getReportRequests(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer mostRecentNum, Status...statuses); | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add method and param descriptions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some JavaDocs, also to related methods.
/** | ||
* @see ReportDAO#getReportsWithPagination(ReportDefinition, Date, Date, Integer, Integer, Status...) | ||
*/ | ||
public ReportRequestDTO getReportsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are returning requests, getReportRequests
looks better than getReports
. Not so? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to getReportRequestsWithPagination
, although the suffix WithPagination
might not be great.
What do you think of adding some tests? |
Added couple of tests. |
<reporting_report_request id="1" uuid="h8a82b63-1066-4c1d-9b43-b405851fc467" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you intentionally change the formatting of these xml dataset files? I notice that you reformatted quite a number of them. I thought you would just add your new records and leave the rest intact. 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added 4th reporting_report_request to all datasets (one for each openMRSMinorVersion) and intentionally formatted the reporting_report_request elements group to have the same style as reporting_report_design elements group just a line above - IMO made sense to do.
*/ | ||
@Transactional(readOnly = true) | ||
public ReportRequestDTO getReportRequestsWithPagination(ReportDefinition reportDefinition, Date requestOnOrAfter, | ||
Date requestOnOrBefore, Integer pageNumber, Integer pageSize, Status...statuses); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you look into this formatting?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it back into one line.
@@ -123,6 +124,11 @@ public List<ReportDesign> getReportDesigns(ReportDefinition reportDefinition, Cl | |||
*/ | |||
public List<ReportRequest> getReportRequests(ReportDefinition reportDefinition, Date requestOnOrAfter, Date requestOnOrBefore, Integer mostRecentNum, Status...statuses); | |||
|
|||
/** | |||
* @return {@link ReportRequestDTO} object which contains report requests and total count data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also document this fully? Or at least use a @see
annotation pointing to where it is properly documented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added see
private long reportRequestCount; | ||
|
||
public ReportRequestDTO(List<ReportRequest> reportRequests, long reportRequestCount) { | ||
this.reportRequests = reportRequests; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just get the reportRequestsCount from reportRequests.size()? Or can we change the variable names to make things clearer? 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the class name to ReportRequestPageDTO
and reportRequestsCount
to totalCount
, so hopefully it should be easily read as "this is some subset of report requests and total count indicates the size of total set"/ " one page from totalCount items".
|
||
import java.util.List; | ||
|
||
public class ReportRequestPageDTO { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to see us not introduce this new ReportRequestPageDTO class, but to just have separate DAO methods - one to get a count of all requests that match the criteria, and one to get the current list of requests that match the criteria. Creating a separate shared method to create the common criteria that would be used would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
@@ -214,7 +216,45 @@ public List<ReportRequest> getReportRequests(ReportDefinition reportDefinition, | |||
} | |||
return c.list(); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a method here that returns an Integer called "getReportRequestCount" or something, that takes in your parameters and returns the rowcount projection only, then modify the below method to just return the List that match your parameters including the pageNumber and pageSize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the method, also removed the "pagination concept", and replaced with more general first result and max results - the page calculation will be added to reporting-rest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thanks @pwargulak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me @pwargulak , thanks for the rework. I made a few minor comments related to the javadoc that seemed inaccurate, but otherwise I think this is good to go.
* @param requestOnOrBefore a Date used to limit result to ReportRequests which ware requested on or before | ||
* (lower or equal filter), nullable | ||
* @param firstResult the first result to be retrieved, not null | ||
* @param maxResults a limit upon the number of Report Requests to be retrieved, not null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The maxResults
does appear that it can be nullable, based on the dao implementation...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* (greater or equal filter), nullable | ||
* @param requestOnOrBefore a Date used to limit result to ReportRequests which ware requested on or before | ||
* (lower or equal filter), nullable | ||
* @param firstResult the first result to be retrieved, not null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The firstResult
does appear that it can be nullable, based on the dao implementation...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -214,7 +216,45 @@ public List<ReportRequest> getReportRequests(ReportDefinition reportDefinition, | |||
} | |||
return c.list(); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thanks @pwargulak
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ready to merge @pwargulak , but all changes made to the reporting module should have a corresponding ticket in the reporting module JIRA project, and the commit message should link back to that ticket, rather than to an O3 ticket. Can you do that?
Moved to #251 to indicate real source of the PR. |
Summary
This change extends
ReportService
with new methodgetReportsWithPagination
used to read ReportRequests for specific report, dates, statuses paginated for performance gains.It was done as part of making of O3 Reports Admin pages.
See the related issue.
Issue
https://openmrs.atlassian.net/browse/REPORT-906