#421 closed defect (fixed)
Sample count report does not always handle all views correctly
Reported by: | olle | Owned by: | olle |
---|---|---|---|
Priority: | major | Milestone: | Reggie v2.9 |
Component: | net.sf.basedb.reggie | Keywords: | |
Cc: |
Description
Sample count report does not always handle all views correctly.
- Data for specific months are sometimes missing, while all month headers are present, leading to data for some months being shown under the header for the previous month, and the data for the last header being all zeroes. A typical example is a start date ending with day 30 or 31 and a period including February.
- Data for weeks are sometimes (always?) shown under the header for the next week.
- Data for years have missing data for the first year.
Change History (8)
comment:1 by , 12 years ago
Status: | new → assigned |
---|
comment:2 by , 12 years ago
Summary: | Sample count report does not always handle month and week views correctly → Sample count report does not always handle all views correctly |
---|
Ticket summary modified to be consistent with the ticket description.
comment:3 by , 12 years ago
Traceability note:
- The report generator was introduced in Ticket #339 (Report generator).
comment:4 by , 12 years ago
Problem discussion:
Data for the report is collected by servlet SampleReportServlet
in reggie/src/net/sf/basedb/reggie/servlet/
, while the table presentation is created by JSP script samplereportgenerator
in reggie/resources/
. Currently, however, the data for the summed values for each site and all sites together are calculated by the JSP script.
The problems seem to have different causes:
- The problem for the monthly view was identified by Nicklas Nordborg as being caused by the way the monthly steps are created in the code, where e.g. 2011-01-30 is followed with what would literally be 2011-02-30, which is re-interpreted by the java method to be equal to 2011-03-02 for a non-leap year, resulting in data for January 2011 being followed by those for March 2011, while data for February 2011 is missing. While the short month of February is the typical case where this problem might appear, all months with less than 31 days might be affected (although only one month for each table).
- The problem for the weekly view seems to be connected with the fact that many week-number methods in Java and JavaScript do not comply with the ISO week numbering system used in the EU.
- The missing data for the first year in the yearly view seems to be the result of a simple bug in the java servlet code (operator
<=
instead of<
).
comment:5 by , 12 years ago
Design of bug fix.
General guidelines:
- Existing code should be reused as much as possible, in order to lessen the risk of introducing new bugs.
- When new variables have to be introduced, they are preferably calculated in the
SampleReportServlet
servlet, and the values transferred to the JSP script.
Fix for the different cases:
- The problem with the monthly view is solved by basing the table columns on a new adjusted start date,
periodStartDate
, that is set to the beginning of the period step the original start date belongs to, e.g. January 1st for the year view, the first day of the quarter for the quarterly view, the first day of the month for the monthly view, and a Monday for the weekly view. This will hopefully ensure that the stepping procedure used to obtain other data columns will work. The value of the the period start date will be calculated in theSampleReportServlet
servlet, and the value transferred to thesamplereportgenerator
JSP script. In order to calculate the period start date, new convenience methodscalculatePeriodStartDate(Date date, String viewType)
,mondayInISOWeek(Date date)
,firstDayInMonth(Date date)
,firstDayInQuarter(Date date)
,firstDayInYear(Date date)
, andadjustDayTime(Date date, int hour, int min, int sec)
are added to theSampleReportServlet
servlet. - In order to get ISO week numbers, the
SampleReportServlet
servlet now uses theGregorianCalendar
class, which is flexible enough to be configured for different week systems, while thesamplereportgenerator
JSP script uses a new functiongetISOWeekNumber(date)
. - The yearly view was fixed by changing
<=
to<
in functionaddDataRowsToTable(report, reportTable)
in thesamplereportgenerator
JSP script, when comparing a year with that of the start date for a site in project.
comment:6 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
comment:7 by , 12 years ago
(In [1739]) Refs #421. JSP script samplereportgenerator.jsp
in reggie/resources/
updated in function createSampleCountReport(report)
to calculate the number of columns correctly for quarterly view, when the start and end dates lie in the same year (this could never happen in the original version, where quarterly view was used only for time periods between 13 months and 3 years). The original calculation assumed that the start and end years were different, and therefore resulted in 4 extra quarter columns.
Ticket accepted.