Fossil SCM
Re-added the 'Total Events' label to /stats_report, but did it outside the table so that the JS sorting does not hose it. Replaced a double calculation with an equivalent int one.
Commit
8adf0db1c8aa3ac217dd7459703c5ddd7ebe22f2
Parent
674a24a3603ed20…
1 file changed
+10
-16
+10
-16
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1885,11 +1885,11 @@ | ||
| 1885 | 1885 | row colors */ |
| 1886 | 1886 | Blob sql = empty_blob; /* SQL */ |
| 1887 | 1887 | char const * zTimeLabel = includeMonth ? "Year/Month" : "Year"; |
| 1888 | 1888 | char zPrevYear[5] = {0}; /* For keeping track of when |
| 1889 | 1889 | we change years while looping */ |
| 1890 | - int nEventsPerYear = 0; /* Total even count for the | |
| 1890 | + int nEventsPerYear = 0; /* Total event count for the | |
| 1891 | 1891 | current year */ |
| 1892 | 1892 | char showYearTotal = 0; /* Flag telling us when to show |
| 1893 | 1893 | the per-year event totals */ |
| 1894 | 1894 | Blob header = empty_blob; /* Page header text */ |
| 1895 | 1895 | int nMaxEvents = 1; /* for calculating length of graph bars. */ |
| @@ -1934,11 +1934,11 @@ | ||
| 1934 | 1934 | db_reset(&query); |
| 1935 | 1935 | while( SQLITE_ROW == db_step(&query) ){ |
| 1936 | 1936 | char const * zTimeframe = db_column_text(&query, 0); |
| 1937 | 1937 | int const nCount = db_column_int(&query, 1); |
| 1938 | 1938 | int const nSize = nCount |
| 1939 | - ? (int)(1.0 * nCount / nMaxEvents * 100) | |
| 1939 | + ? (int)(100 * nCount / nMaxEvents) | |
| 1940 | 1940 | : 1; |
| 1941 | 1941 | showYearTotal = 0; |
| 1942 | 1942 | if(includeMonth){ |
| 1943 | 1943 | /* For Month/year view, add a separator for each distinct year. */ |
| 1944 | 1944 | if(!*zPrevYear || |
| @@ -2002,27 +2002,23 @@ | ||
| 2002 | 2002 | /* |
| 2003 | 2003 | Potential improvement: calculate the min/max event counts and |
| 2004 | 2004 | use percent-based graph bars. |
| 2005 | 2005 | */ |
| 2006 | 2006 | } |
| 2007 | - | |
| 2007 | + db_finalize(&query); | |
| 2008 | 2008 | if(includeMonth && !showYearTotal && *zPrevYear){ |
| 2009 | 2009 | /* Add final year total separator. */ |
| 2010 | 2010 | rowClass = ++nRowNumber % 2; |
| 2011 | 2011 | @ <tr class='row%d(rowClass)'> |
| 2012 | 2012 | @ <td></td> |
| 2013 | 2013 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2014 | 2014 | @</tr> |
| 2015 | 2015 | } |
| 2016 | -#if 0 | |
| 2017 | - rowClass = ++nRowNumber % 2; | |
| 2018 | - @ <tr class='row%d(rowClass)'> | |
| 2019 | - @ <td colspan='3'>Total events: %d(nEventTotal)</td> | |
| 2020 | - @ </tr> | |
| 2021 | -#endif | |
| 2022 | 2016 | @ </tbody></table> |
| 2023 | - db_finalize(&query); | |
| 2017 | + if(nEventTotal){ | |
| 2018 | + @ <br><div>Total events: %d(nEventTotal)</div> | |
| 2019 | + } | |
| 2024 | 2020 | if( !includeMonth ){ |
| 2025 | 2021 | output_table_sorting_javascript("statsTable","tnx"); |
| 2026 | 2022 | } |
| 2027 | 2023 | } |
| 2028 | 2024 | |
| @@ -2064,11 +2060,11 @@ | ||
| 2064 | 2060 | db_reset(&query); |
| 2065 | 2061 | while( SQLITE_ROW == db_step(&query) ){ |
| 2066 | 2062 | char const * zUser = db_column_text(&query, 0); |
| 2067 | 2063 | int const nCount = db_column_int(&query, 1); |
| 2068 | 2064 | int const nSize = nCount |
| 2069 | - ? (int)(1.0 * nCount / nMaxEvents * 100) | |
| 2065 | + ? (int)(100 * nCount / nMaxEvents) | |
| 2070 | 2066 | : 0; |
| 2071 | 2067 | if(!nCount) continue /* arguable! Possible? */; |
| 2072 | 2068 | rowClass = ++nRowNumber % 2; |
| 2073 | 2069 | nEventTotal += nCount; |
| 2074 | 2070 | @<tr class='row%d(rowClass)'> |
| @@ -2176,11 +2172,11 @@ | ||
| 2176 | 2172 | db_reset(&stWeek); |
| 2177 | 2173 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2178 | 2174 | char const * zWeek = db_column_text(&stWeek,0); |
| 2179 | 2175 | int const nCount = db_column_int(&stWeek,1); |
| 2180 | 2176 | int const nSize = nCount |
| 2181 | - ? (int)(1.0 * nCount / nMaxEvents * 100) | |
| 2177 | + ? (int)(100 * nCount / nMaxEvents) | |
| 2182 | 2178 | : 0; |
| 2183 | 2179 | total += nCount; |
| 2184 | 2180 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2185 | 2181 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| 2186 | 2182 | g.zTop, zYear, zWeek, nCount); |
| @@ -2198,17 +2194,15 @@ | ||
| 2198 | 2194 | } |
| 2199 | 2195 | cgi_printf("</td></tr>"); |
| 2200 | 2196 | } |
| 2201 | 2197 | db_finalize(&stWeek); |
| 2202 | 2198 | free(zDefaultYear); |
| 2199 | + cgi_printf("</tbody></table>"); | |
| 2203 | 2200 | if(total){ |
| 2204 | - cgi_printf("<tr class='row%d'>", ++rowCount%2); | |
| 2205 | - cgi_printf("<td colspan='2'>Total events:</td><td>%d</td>", | |
| 2201 | + cgi_printf("<br><div>Total events: %d</div>", | |
| 2206 | 2202 | total); |
| 2207 | - cgi_printf("</tr>"); | |
| 2208 | 2203 | } |
| 2209 | - cgi_printf("</tbody></table>"); | |
| 2210 | 2204 | output_table_sorting_javascript("statsTable","tnx"); |
| 2211 | 2205 | } |
| 2212 | 2206 | } |
| 2213 | 2207 | |
| 2214 | 2208 | /* |
| 2215 | 2209 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1885,11 +1885,11 @@ | |
| 1885 | row colors */ |
| 1886 | Blob sql = empty_blob; /* SQL */ |
| 1887 | char const * zTimeLabel = includeMonth ? "Year/Month" : "Year"; |
| 1888 | char zPrevYear[5] = {0}; /* For keeping track of when |
| 1889 | we change years while looping */ |
| 1890 | int nEventsPerYear = 0; /* Total even count for the |
| 1891 | current year */ |
| 1892 | char showYearTotal = 0; /* Flag telling us when to show |
| 1893 | the per-year event totals */ |
| 1894 | Blob header = empty_blob; /* Page header text */ |
| 1895 | int nMaxEvents = 1; /* for calculating length of graph bars. */ |
| @@ -1934,11 +1934,11 @@ | |
| 1934 | db_reset(&query); |
| 1935 | while( SQLITE_ROW == db_step(&query) ){ |
| 1936 | char const * zTimeframe = db_column_text(&query, 0); |
| 1937 | int const nCount = db_column_int(&query, 1); |
| 1938 | int const nSize = nCount |
| 1939 | ? (int)(1.0 * nCount / nMaxEvents * 100) |
| 1940 | : 1; |
| 1941 | showYearTotal = 0; |
| 1942 | if(includeMonth){ |
| 1943 | /* For Month/year view, add a separator for each distinct year. */ |
| 1944 | if(!*zPrevYear || |
| @@ -2002,27 +2002,23 @@ | |
| 2002 | /* |
| 2003 | Potential improvement: calculate the min/max event counts and |
| 2004 | use percent-based graph bars. |
| 2005 | */ |
| 2006 | } |
| 2007 | |
| 2008 | if(includeMonth && !showYearTotal && *zPrevYear){ |
| 2009 | /* Add final year total separator. */ |
| 2010 | rowClass = ++nRowNumber % 2; |
| 2011 | @ <tr class='row%d(rowClass)'> |
| 2012 | @ <td></td> |
| 2013 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2014 | @</tr> |
| 2015 | } |
| 2016 | #if 0 |
| 2017 | rowClass = ++nRowNumber % 2; |
| 2018 | @ <tr class='row%d(rowClass)'> |
| 2019 | @ <td colspan='3'>Total events: %d(nEventTotal)</td> |
| 2020 | @ </tr> |
| 2021 | #endif |
| 2022 | @ </tbody></table> |
| 2023 | db_finalize(&query); |
| 2024 | if( !includeMonth ){ |
| 2025 | output_table_sorting_javascript("statsTable","tnx"); |
| 2026 | } |
| 2027 | } |
| 2028 | |
| @@ -2064,11 +2060,11 @@ | |
| 2064 | db_reset(&query); |
| 2065 | while( SQLITE_ROW == db_step(&query) ){ |
| 2066 | char const * zUser = db_column_text(&query, 0); |
| 2067 | int const nCount = db_column_int(&query, 1); |
| 2068 | int const nSize = nCount |
| 2069 | ? (int)(1.0 * nCount / nMaxEvents * 100) |
| 2070 | : 0; |
| 2071 | if(!nCount) continue /* arguable! Possible? */; |
| 2072 | rowClass = ++nRowNumber % 2; |
| 2073 | nEventTotal += nCount; |
| 2074 | @<tr class='row%d(rowClass)'> |
| @@ -2176,11 +2172,11 @@ | |
| 2176 | db_reset(&stWeek); |
| 2177 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2178 | char const * zWeek = db_column_text(&stWeek,0); |
| 2179 | int const nCount = db_column_int(&stWeek,1); |
| 2180 | int const nSize = nCount |
| 2181 | ? (int)(1.0 * nCount / nMaxEvents * 100) |
| 2182 | : 0; |
| 2183 | total += nCount; |
| 2184 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2185 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| 2186 | g.zTop, zYear, zWeek, nCount); |
| @@ -2198,17 +2194,15 @@ | |
| 2198 | } |
| 2199 | cgi_printf("</td></tr>"); |
| 2200 | } |
| 2201 | db_finalize(&stWeek); |
| 2202 | free(zDefaultYear); |
| 2203 | if(total){ |
| 2204 | cgi_printf("<tr class='row%d'>", ++rowCount%2); |
| 2205 | cgi_printf("<td colspan='2'>Total events:</td><td>%d</td>", |
| 2206 | total); |
| 2207 | cgi_printf("</tr>"); |
| 2208 | } |
| 2209 | cgi_printf("</tbody></table>"); |
| 2210 | output_table_sorting_javascript("statsTable","tnx"); |
| 2211 | } |
| 2212 | } |
| 2213 | |
| 2214 | /* |
| 2215 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1885,11 +1885,11 @@ | |
| 1885 | row colors */ |
| 1886 | Blob sql = empty_blob; /* SQL */ |
| 1887 | char const * zTimeLabel = includeMonth ? "Year/Month" : "Year"; |
| 1888 | char zPrevYear[5] = {0}; /* For keeping track of when |
| 1889 | we change years while looping */ |
| 1890 | int nEventsPerYear = 0; /* Total event count for the |
| 1891 | current year */ |
| 1892 | char showYearTotal = 0; /* Flag telling us when to show |
| 1893 | the per-year event totals */ |
| 1894 | Blob header = empty_blob; /* Page header text */ |
| 1895 | int nMaxEvents = 1; /* for calculating length of graph bars. */ |
| @@ -1934,11 +1934,11 @@ | |
| 1934 | db_reset(&query); |
| 1935 | while( SQLITE_ROW == db_step(&query) ){ |
| 1936 | char const * zTimeframe = db_column_text(&query, 0); |
| 1937 | int const nCount = db_column_int(&query, 1); |
| 1938 | int const nSize = nCount |
| 1939 | ? (int)(100 * nCount / nMaxEvents) |
| 1940 | : 1; |
| 1941 | showYearTotal = 0; |
| 1942 | if(includeMonth){ |
| 1943 | /* For Month/year view, add a separator for each distinct year. */ |
| 1944 | if(!*zPrevYear || |
| @@ -2002,27 +2002,23 @@ | |
| 2002 | /* |
| 2003 | Potential improvement: calculate the min/max event counts and |
| 2004 | use percent-based graph bars. |
| 2005 | */ |
| 2006 | } |
| 2007 | db_finalize(&query); |
| 2008 | if(includeMonth && !showYearTotal && *zPrevYear){ |
| 2009 | /* Add final year total separator. */ |
| 2010 | rowClass = ++nRowNumber % 2; |
| 2011 | @ <tr class='row%d(rowClass)'> |
| 2012 | @ <td></td> |
| 2013 | @ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td> |
| 2014 | @</tr> |
| 2015 | } |
| 2016 | @ </tbody></table> |
| 2017 | if(nEventTotal){ |
| 2018 | @ <br><div>Total events: %d(nEventTotal)</div> |
| 2019 | } |
| 2020 | if( !includeMonth ){ |
| 2021 | output_table_sorting_javascript("statsTable","tnx"); |
| 2022 | } |
| 2023 | } |
| 2024 | |
| @@ -2064,11 +2060,11 @@ | |
| 2060 | db_reset(&query); |
| 2061 | while( SQLITE_ROW == db_step(&query) ){ |
| 2062 | char const * zUser = db_column_text(&query, 0); |
| 2063 | int const nCount = db_column_int(&query, 1); |
| 2064 | int const nSize = nCount |
| 2065 | ? (int)(100 * nCount / nMaxEvents) |
| 2066 | : 0; |
| 2067 | if(!nCount) continue /* arguable! Possible? */; |
| 2068 | rowClass = ++nRowNumber % 2; |
| 2069 | nEventTotal += nCount; |
| 2070 | @<tr class='row%d(rowClass)'> |
| @@ -2176,11 +2172,11 @@ | |
| 2172 | db_reset(&stWeek); |
| 2173 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2174 | char const * zWeek = db_column_text(&stWeek,0); |
| 2175 | int const nCount = db_column_int(&stWeek,1); |
| 2176 | int const nSize = nCount |
| 2177 | ? (int)(100 * nCount / nMaxEvents) |
| 2178 | : 0; |
| 2179 | total += nCount; |
| 2180 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2181 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| 2182 | g.zTop, zYear, zWeek, nCount); |
| @@ -2198,17 +2194,15 @@ | |
| 2194 | } |
| 2195 | cgi_printf("</td></tr>"); |
| 2196 | } |
| 2197 | db_finalize(&stWeek); |
| 2198 | free(zDefaultYear); |
| 2199 | cgi_printf("</tbody></table>"); |
| 2200 | if(total){ |
| 2201 | cgi_printf("<br><div>Total events: %d</div>", |
| 2202 | total); |
| 2203 | } |
| 2204 | output_table_sorting_javascript("statsTable","tnx"); |
| 2205 | } |
| 2206 | } |
| 2207 | |
| 2208 | /* |
| 2209 |