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.

stephan 2013-07-20 17:04 trunk
Commit 8adf0db1c8aa3ac217dd7459703c5ddd7ebe22f2
1 file changed +10 -16
+10 -16
--- src/timeline.c
+++ src/timeline.c
@@ -1885,11 +1885,11 @@
18851885
row colors */
18861886
Blob sql = empty_blob; /* SQL */
18871887
char const * zTimeLabel = includeMonth ? "Year/Month" : "Year";
18881888
char zPrevYear[5] = {0}; /* For keeping track of when
18891889
we change years while looping */
1890
- int nEventsPerYear = 0; /* Total even count for the
1890
+ int nEventsPerYear = 0; /* Total event count for the
18911891
current year */
18921892
char showYearTotal = 0; /* Flag telling us when to show
18931893
the per-year event totals */
18941894
Blob header = empty_blob; /* Page header text */
18951895
int nMaxEvents = 1; /* for calculating length of graph bars. */
@@ -1934,11 +1934,11 @@
19341934
db_reset(&query);
19351935
while( SQLITE_ROW == db_step(&query) ){
19361936
char const * zTimeframe = db_column_text(&query, 0);
19371937
int const nCount = db_column_int(&query, 1);
19381938
int const nSize = nCount
1939
- ? (int)(1.0 * nCount / nMaxEvents * 100)
1939
+ ? (int)(100 * nCount / nMaxEvents)
19401940
: 1;
19411941
showYearTotal = 0;
19421942
if(includeMonth){
19431943
/* For Month/year view, add a separator for each distinct year. */
19441944
if(!*zPrevYear ||
@@ -2002,27 +2002,23 @@
20022002
/*
20032003
Potential improvement: calculate the min/max event counts and
20042004
use percent-based graph bars.
20052005
*/
20062006
}
2007
-
2007
+ db_finalize(&query);
20082008
if(includeMonth && !showYearTotal && *zPrevYear){
20092009
/* Add final year total separator. */
20102010
rowClass = ++nRowNumber % 2;
20112011
@ <tr class='row%d(rowClass)'>
20122012
@ <td></td>
20132013
@ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
20142014
@</tr>
20152015
}
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
20222016
@ </tbody></table>
2023
- db_finalize(&query);
2017
+ if(nEventTotal){
2018
+ @ <br><div>Total events: %d(nEventTotal)</div>
2019
+ }
20242020
if( !includeMonth ){
20252021
output_table_sorting_javascript("statsTable","tnx");
20262022
}
20272023
}
20282024
@@ -2064,11 +2060,11 @@
20642060
db_reset(&query);
20652061
while( SQLITE_ROW == db_step(&query) ){
20662062
char const * zUser = db_column_text(&query, 0);
20672063
int const nCount = db_column_int(&query, 1);
20682064
int const nSize = nCount
2069
- ? (int)(1.0 * nCount / nMaxEvents * 100)
2065
+ ? (int)(100 * nCount / nMaxEvents)
20702066
: 0;
20712067
if(!nCount) continue /* arguable! Possible? */;
20722068
rowClass = ++nRowNumber % 2;
20732069
nEventTotal += nCount;
20742070
@<tr class='row%d(rowClass)'>
@@ -2176,11 +2172,11 @@
21762172
db_reset(&stWeek);
21772173
while( SQLITE_ROW == db_step(&stWeek) ){
21782174
char const * zWeek = db_column_text(&stWeek,0);
21792175
int const nCount = db_column_int(&stWeek,1);
21802176
int const nSize = nCount
2181
- ? (int)(1.0 * nCount / nMaxEvents * 100)
2177
+ ? (int)(100 * nCount / nMaxEvents)
21822178
: 0;
21832179
total += nCount;
21842180
cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
21852181
cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d",
21862182
g.zTop, zYear, zWeek, nCount);
@@ -2198,17 +2194,15 @@
21982194
}
21992195
cgi_printf("</td></tr>");
22002196
}
22012197
db_finalize(&stWeek);
22022198
free(zDefaultYear);
2199
+ cgi_printf("</tbody></table>");
22032200
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>",
22062202
total);
2207
- cgi_printf("</tr>");
22082203
}
2209
- cgi_printf("</tbody></table>");
22102204
output_table_sorting_javascript("statsTable","tnx");
22112205
}
22122206
}
22132207
22142208
/*
22152209
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button