Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#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 Changed 7 years ago by olle

Status: newassigned

Ticket accepted.

comment:2 Changed 7 years ago by olle

Summary: Sample count report does not always handle month and week views correctlySample count report does not always handle all views correctly

Ticket summary modified to be consistent with the ticket description.

comment:3 Changed 7 years ago by olle

Traceability note:

  • The report generator was introduced in Ticket #339 (Report generator).

comment:4 Changed 7 years ago by olle

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:

  1. 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).
  2. 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.
  3. 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 <).

Last edited 7 years ago by olle (previous) (diff)

comment:5 Changed 7 years ago by olle

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:

  1. 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 the SampleReportServlet servlet, and the value transferred to the samplereportgenerator JSP script. In order to calculate the period start date, new convenience methods calculatePeriodStartDate(Date date, String viewType), mondayInISOWeek(Date date), firstDayInMonth(Date date), firstDayInQuarter(Date date), firstDayInYear(Date date), and adjustDayTime(Date date, int hour, int min, int sec) are added to the SampleReportServlet servlet.
  2. In order to get ISO week numbers, the SampleReportServlet servlet now uses the GregorianCalendar class, which is flexible enough to be configured for different week systems, while the samplereportgenerator JSP script uses a new function getISOWeekNumber(date).
  3. The yearly view was fixed by changing <= to < in function addDataRowsToTable(report, reportTable) in the samplereportgenerator JSP script, when comparing a year with that of the start date for a site in project.

comment:6 Changed 7 years ago by olle

Resolution: fixed
Status: assignedclosed

(In [1727]) Fixes #421. Bug fixes for problems with different period views.

comment:7 Changed 7 years ago by olle

(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.

Last edited 7 years ago by olle (previous) (diff)

comment:8 Changed 7 years ago by olle

(In [1743]) Refs #421. JSP script samplereportgenerator.jsp in reggie/resources/ updated in function createSampleCountReport(report) to set default value to 0, when adding values for combined data for sites.

Note: See TracTickets for help on using tickets.