Fossil SCM

Added by-type labels for /reports page headers, but still not sure how to integrate the flags sensibly into the UI.

stephan 2013-10-11 19:04 trunk
Commit 0761df83b09ddb5e7b2fbaab37bfb74f228e7275
1 file changed +32 -10
+32 -10
--- src/timeline.c
+++ src/timeline.c
@@ -1869,14 +1869,14 @@
18691869
**
18701870
** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
18711871
** filter it applies, or '*' if no filter is applied (i.e. if "all" is
18721872
** used).
18731873
*/
1874
-static char stats_report_init_view(){
1874
+static int stats_report_init_view(){
18751875
char const * zType = PD("type","*"); /* analog to /timeline?y=... */
18761876
char const * zRealType = NULL; /* normalized form of zType */
1877
- char rc = 0; /* result code */
1877
+ int rc = 0; /* result code */
18781878
switch( (zType && *zType) ? *zType : 0 ){
18791879
case 'c':
18801880
case 'C':
18811881
zRealType = "ci";
18821882
rc = *zRealType;
@@ -1914,10 +1914,30 @@
19141914
db_multi_exec("CREATE TEMP VIEW v_reports AS "
19151915
"SELECT * FROM event");
19161916
}
19171917
return rc;
19181918
}
1919
+
1920
+/*
1921
+** Expects to be passed the return value of stats_report_init_view(),
1922
+** and returns a string suitable (for a given value of suitable) for
1923
+** use in a label. The returned bytes are static.
1924
+*/
1925
+static char const * stats_report_label_for_type( int reportType ){
1926
+ switch( reportType ){
1927
+ case 'c':
1928
+ return "commits";
1929
+ case 'w':
1930
+ return "wiki changes";
1931
+ case 't':
1932
+ return "ticket changes";
1933
+ case 'g':
1934
+ return "tag changes";
1935
+ default:
1936
+ return "all types";
1937
+ }
1938
+}
19191939
19201940
19211941
/*
19221942
** Helper for stats_report_by_month_year(), which generates a list of
19231943
** week numbers. zTimeframe should be either a timeframe in the form YYYY
@@ -1973,12 +1993,13 @@
19731993
Blob header = empty_blob; /* Page header text */
19741994
int nMaxEvents = 1; /* for calculating length of graph
19751995
bars. */
19761996
int iterations = 0; /* number of weeks/months we iterate
19771997
over */
1978
- stats_report_init_view();
1979
- blob_appendf(&header, "Timeline Events by year%s",
1998
+ int reportType = stats_report_init_view();
1999
+ blob_appendf(&header, "Timeline Events (%s) by year%s",
2000
+ stats_report_label_for_type(reportType),
19802001
(includeMonth ? "/month" : ""));
19812002
blob_appendf(&sql,
19822003
"SELECT substr(date(mtime),1,%d) AS timeframe, "
19832004
"count(*) AS eventCount "
19842005
"FROM v_reports ",
@@ -2119,20 +2140,21 @@
21192140
int rowClass = 0; /* counter for alternating
21202141
row colors */
21212142
Blob sql = empty_blob; /* SQL */
21222143
int nMaxEvents = 1; /* max number of events for
21232144
all rows. */
2124
- stats_report_init_view();
2145
+ int reportType = stats_report_init_view();
21252146
blob_append(&sql,
21262147
"SELECT user, "
21272148
"COUNT(*) AS eventCount "
21282149
"FROM v_reports "
21292150
"GROUP BY user ORDER BY eventCount DESC",
21302151
-1);
21312152
db_prepare(&query, blob_str(&sql));
21322153
blob_reset(&sql);
2133
- @ <h1>Timeline Events by User</h1>
2154
+ @ <h1>Timeline Events
2155
+ @ (%s(stats_report_label_for_type(reportType))) by User</h1>
21342156
@ <table class='statistics-report-table-events' border='0'
21352157
@ cellpadding='2' cellspacing='0' id='statsTable'>
21362158
@ <thead><tr>
21372159
@ <th>User</th>
21382160
@ <th>Events</th>
@@ -2187,12 +2209,11 @@
21872209
char * zDefaultYear = NULL;
21882210
Blob sql = empty_blob;
21892211
int nMaxEvents = 1; /* max number of events for
21902212
all rows. */
21912213
int iterations = 0; /* # of active time periods. */
2192
-
2193
- stats_report_init_view();
2214
+ int reportType = stats_report_init_view();
21942215
cgi_printf("Select year: ");
21952216
blob_append(&sql,
21962217
"SELECT DISTINCT substr(date(mtime),1,4) AS y "
21972218
"FROM v_reports WHERE 1 ", -1);
21982219
if(zUserName&&*zUserName){
@@ -2222,12 +2243,13 @@
22222243
if(4 == nYear){
22232244
Stmt stWeek = empty_Stmt;
22242245
int rowCount = 0;
22252246
int total = 0;
22262247
Blob header = empty_blob;
2227
- blob_appendf(&header, "Timeline events for the calendar weeks "
2228
- "of %h", zYear);
2248
+ blob_appendf(&header, "Timeline events (%s) for the calendar weeks "
2249
+ "of %h", stats_report_label_for_type(reportType),
2250
+ zYear);
22292251
blob_appendf(&sql,
22302252
"SELECT DISTINCT strftime('%%%%W',mtime) AS wk, "
22312253
"count(*) AS n "
22322254
"FROM v_reports "
22332255
"WHERE %Q=substr(date(mtime),1,4) "
22342256
--- src/timeline.c
+++ src/timeline.c
@@ -1869,14 +1869,14 @@
1869 **
1870 ** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
1871 ** filter it applies, or '*' if no filter is applied (i.e. if "all" is
1872 ** used).
1873 */
1874 static char stats_report_init_view(){
1875 char const * zType = PD("type","*"); /* analog to /timeline?y=... */
1876 char const * zRealType = NULL; /* normalized form of zType */
1877 char rc = 0; /* result code */
1878 switch( (zType && *zType) ? *zType : 0 ){
1879 case 'c':
1880 case 'C':
1881 zRealType = "ci";
1882 rc = *zRealType;
@@ -1914,10 +1914,30 @@
1914 db_multi_exec("CREATE TEMP VIEW v_reports AS "
1915 "SELECT * FROM event");
1916 }
1917 return rc;
1918 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1919
1920
1921 /*
1922 ** Helper for stats_report_by_month_year(), which generates a list of
1923 ** week numbers. zTimeframe should be either a timeframe in the form YYYY
@@ -1973,12 +1993,13 @@
1973 Blob header = empty_blob; /* Page header text */
1974 int nMaxEvents = 1; /* for calculating length of graph
1975 bars. */
1976 int iterations = 0; /* number of weeks/months we iterate
1977 over */
1978 stats_report_init_view();
1979 blob_appendf(&header, "Timeline Events by year%s",
 
1980 (includeMonth ? "/month" : ""));
1981 blob_appendf(&sql,
1982 "SELECT substr(date(mtime),1,%d) AS timeframe, "
1983 "count(*) AS eventCount "
1984 "FROM v_reports ",
@@ -2119,20 +2140,21 @@
2119 int rowClass = 0; /* counter for alternating
2120 row colors */
2121 Blob sql = empty_blob; /* SQL */
2122 int nMaxEvents = 1; /* max number of events for
2123 all rows. */
2124 stats_report_init_view();
2125 blob_append(&sql,
2126 "SELECT user, "
2127 "COUNT(*) AS eventCount "
2128 "FROM v_reports "
2129 "GROUP BY user ORDER BY eventCount DESC",
2130 -1);
2131 db_prepare(&query, blob_str(&sql));
2132 blob_reset(&sql);
2133 @ <h1>Timeline Events by User</h1>
 
2134 @ <table class='statistics-report-table-events' border='0'
2135 @ cellpadding='2' cellspacing='0' id='statsTable'>
2136 @ <thead><tr>
2137 @ <th>User</th>
2138 @ <th>Events</th>
@@ -2187,12 +2209,11 @@
2187 char * zDefaultYear = NULL;
2188 Blob sql = empty_blob;
2189 int nMaxEvents = 1; /* max number of events for
2190 all rows. */
2191 int iterations = 0; /* # of active time periods. */
2192
2193 stats_report_init_view();
2194 cgi_printf("Select year: ");
2195 blob_append(&sql,
2196 "SELECT DISTINCT substr(date(mtime),1,4) AS y "
2197 "FROM v_reports WHERE 1 ", -1);
2198 if(zUserName&&*zUserName){
@@ -2222,12 +2243,13 @@
2222 if(4 == nYear){
2223 Stmt stWeek = empty_Stmt;
2224 int rowCount = 0;
2225 int total = 0;
2226 Blob header = empty_blob;
2227 blob_appendf(&header, "Timeline events for the calendar weeks "
2228 "of %h", zYear);
 
2229 blob_appendf(&sql,
2230 "SELECT DISTINCT strftime('%%%%W',mtime) AS wk, "
2231 "count(*) AS n "
2232 "FROM v_reports "
2233 "WHERE %Q=substr(date(mtime),1,4) "
2234
--- src/timeline.c
+++ src/timeline.c
@@ -1869,14 +1869,14 @@
1869 **
1870 ** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
1871 ** filter it applies, or '*' if no filter is applied (i.e. if "all" is
1872 ** used).
1873 */
1874 static int stats_report_init_view(){
1875 char const * zType = PD("type","*"); /* analog to /timeline?y=... */
1876 char const * zRealType = NULL; /* normalized form of zType */
1877 int rc = 0; /* result code */
1878 switch( (zType && *zType) ? *zType : 0 ){
1879 case 'c':
1880 case 'C':
1881 zRealType = "ci";
1882 rc = *zRealType;
@@ -1914,10 +1914,30 @@
1914 db_multi_exec("CREATE TEMP VIEW v_reports AS "
1915 "SELECT * FROM event");
1916 }
1917 return rc;
1918 }
1919
1920 /*
1921 ** Expects to be passed the return value of stats_report_init_view(),
1922 ** and returns a string suitable (for a given value of suitable) for
1923 ** use in a label. The returned bytes are static.
1924 */
1925 static char const * stats_report_label_for_type( int reportType ){
1926 switch( reportType ){
1927 case 'c':
1928 return "commits";
1929 case 'w':
1930 return "wiki changes";
1931 case 't':
1932 return "ticket changes";
1933 case 'g':
1934 return "tag changes";
1935 default:
1936 return "all types";
1937 }
1938 }
1939
1940
1941 /*
1942 ** Helper for stats_report_by_month_year(), which generates a list of
1943 ** week numbers. zTimeframe should be either a timeframe in the form YYYY
@@ -1973,12 +1993,13 @@
1993 Blob header = empty_blob; /* Page header text */
1994 int nMaxEvents = 1; /* for calculating length of graph
1995 bars. */
1996 int iterations = 0; /* number of weeks/months we iterate
1997 over */
1998 int reportType = stats_report_init_view();
1999 blob_appendf(&header, "Timeline Events (%s) by year%s",
2000 stats_report_label_for_type(reportType),
2001 (includeMonth ? "/month" : ""));
2002 blob_appendf(&sql,
2003 "SELECT substr(date(mtime),1,%d) AS timeframe, "
2004 "count(*) AS eventCount "
2005 "FROM v_reports ",
@@ -2119,20 +2140,21 @@
2140 int rowClass = 0; /* counter for alternating
2141 row colors */
2142 Blob sql = empty_blob; /* SQL */
2143 int nMaxEvents = 1; /* max number of events for
2144 all rows. */
2145 int reportType = stats_report_init_view();
2146 blob_append(&sql,
2147 "SELECT user, "
2148 "COUNT(*) AS eventCount "
2149 "FROM v_reports "
2150 "GROUP BY user ORDER BY eventCount DESC",
2151 -1);
2152 db_prepare(&query, blob_str(&sql));
2153 blob_reset(&sql);
2154 @ <h1>Timeline Events
2155 @ (%s(stats_report_label_for_type(reportType))) by User</h1>
2156 @ <table class='statistics-report-table-events' border='0'
2157 @ cellpadding='2' cellspacing='0' id='statsTable'>
2158 @ <thead><tr>
2159 @ <th>User</th>
2160 @ <th>Events</th>
@@ -2187,12 +2209,11 @@
2209 char * zDefaultYear = NULL;
2210 Blob sql = empty_blob;
2211 int nMaxEvents = 1; /* max number of events for
2212 all rows. */
2213 int iterations = 0; /* # of active time periods. */
2214 int reportType = stats_report_init_view();
 
2215 cgi_printf("Select year: ");
2216 blob_append(&sql,
2217 "SELECT DISTINCT substr(date(mtime),1,4) AS y "
2218 "FROM v_reports WHERE 1 ", -1);
2219 if(zUserName&&*zUserName){
@@ -2222,12 +2243,13 @@
2243 if(4 == nYear){
2244 Stmt stWeek = empty_Stmt;
2245 int rowCount = 0;
2246 int total = 0;
2247 Blob header = empty_blob;
2248 blob_appendf(&header, "Timeline events (%s) for the calendar weeks "
2249 "of %h", stats_report_label_for_type(reportType),
2250 zYear);
2251 blob_appendf(&sql,
2252 "SELECT DISTINCT strftime('%%%%W',mtime) AS wk, "
2253 "count(*) AS n "
2254 "FROM v_reports "
2255 "WHERE %Q=substr(date(mtime),1,4) "
2256

Keyboard Shortcuts

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