Sunday, 8 March 2009

Bug: Divide by zero in sparse monthly log trend analysis

If only one weight was present in the most recent log and no entries existed in the previous month's log for the preceding week, the {\tt trendfit::fitSlope()} method would divide by zero because there were insufficient points to fit a linear trend. I added code to the method which reports a zero trend slope when insufficient points are available to fit a slope. Note that while this was discovered testing the new method of computing the trend for the current month, the bug was present prior to the change.

Feature: Trend analysis for current monthly log

When displaying the current (or most recent) monthly log, the trend analysis displayed beneath the chart was based on the data plotted in the chart. At the start of a month, when there were only a few data points, this could result in day-to-day instability in the trend analysis. I added code to test whether the most recent log is being displayed and, if so, a trend for the last seven days is computed using a {\tt history} object, even if that requires retrieving days from the previous month. This also ensures that the trend reported on the monthly log page will always be identical to that shown for the last week in the Trend Analysis page.