Fossil SCM
Added by-type labels for /reports page headers, but still not sure how to integrate the flags sensibly into the UI.
Commit
0761df83b09ddb5e7b2fbaab37bfb74f228e7275
Parent
7f5fbf95ebbf1ca…
1 file changed
+32
-10
+32
-10
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1869,14 +1869,14 @@ | ||
| 1869 | 1869 | ** |
| 1870 | 1870 | ** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of |
| 1871 | 1871 | ** filter it applies, or '*' if no filter is applied (i.e. if "all" is |
| 1872 | 1872 | ** used). |
| 1873 | 1873 | */ |
| 1874 | -static char stats_report_init_view(){ | |
| 1874 | +static int stats_report_init_view(){ | |
| 1875 | 1875 | char const * zType = PD("type","*"); /* analog to /timeline?y=... */ |
| 1876 | 1876 | char const * zRealType = NULL; /* normalized form of zType */ |
| 1877 | - char rc = 0; /* result code */ | |
| 1877 | + int rc = 0; /* result code */ | |
| 1878 | 1878 | switch( (zType && *zType) ? *zType : 0 ){ |
| 1879 | 1879 | case 'c': |
| 1880 | 1880 | case 'C': |
| 1881 | 1881 | zRealType = "ci"; |
| 1882 | 1882 | rc = *zRealType; |
| @@ -1914,10 +1914,30 @@ | ||
| 1914 | 1914 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 1915 | 1915 | "SELECT * FROM event"); |
| 1916 | 1916 | } |
| 1917 | 1917 | return rc; |
| 1918 | 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 | +} | |
| 1919 | 1939 | |
| 1920 | 1940 | |
| 1921 | 1941 | /* |
| 1922 | 1942 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 1923 | 1943 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| @@ -1973,12 +1993,13 @@ | ||
| 1973 | 1993 | Blob header = empty_blob; /* Page header text */ |
| 1974 | 1994 | int nMaxEvents = 1; /* for calculating length of graph |
| 1975 | 1995 | bars. */ |
| 1976 | 1996 | int iterations = 0; /* number of weeks/months we iterate |
| 1977 | 1997 | 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), | |
| 1980 | 2001 | (includeMonth ? "/month" : "")); |
| 1981 | 2002 | blob_appendf(&sql, |
| 1982 | 2003 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| 1983 | 2004 | "count(*) AS eventCount " |
| 1984 | 2005 | "FROM v_reports ", |
| @@ -2119,20 +2140,21 @@ | ||
| 2119 | 2140 | int rowClass = 0; /* counter for alternating |
| 2120 | 2141 | row colors */ |
| 2121 | 2142 | Blob sql = empty_blob; /* SQL */ |
| 2122 | 2143 | int nMaxEvents = 1; /* max number of events for |
| 2123 | 2144 | all rows. */ |
| 2124 | - stats_report_init_view(); | |
| 2145 | + int reportType = stats_report_init_view(); | |
| 2125 | 2146 | blob_append(&sql, |
| 2126 | 2147 | "SELECT user, " |
| 2127 | 2148 | "COUNT(*) AS eventCount " |
| 2128 | 2149 | "FROM v_reports " |
| 2129 | 2150 | "GROUP BY user ORDER BY eventCount DESC", |
| 2130 | 2151 | -1); |
| 2131 | 2152 | db_prepare(&query, blob_str(&sql)); |
| 2132 | 2153 | 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> | |
| 2134 | 2156 | @ <table class='statistics-report-table-events' border='0' |
| 2135 | 2157 | @ cellpadding='2' cellspacing='0' id='statsTable'> |
| 2136 | 2158 | @ <thead><tr> |
| 2137 | 2159 | @ <th>User</th> |
| 2138 | 2160 | @ <th>Events</th> |
| @@ -2187,12 +2209,11 @@ | ||
| 2187 | 2209 | char * zDefaultYear = NULL; |
| 2188 | 2210 | Blob sql = empty_blob; |
| 2189 | 2211 | int nMaxEvents = 1; /* max number of events for |
| 2190 | 2212 | all rows. */ |
| 2191 | 2213 | int iterations = 0; /* # of active time periods. */ |
| 2192 | - | |
| 2193 | - stats_report_init_view(); | |
| 2214 | + int reportType = stats_report_init_view(); | |
| 2194 | 2215 | cgi_printf("Select year: "); |
| 2195 | 2216 | blob_append(&sql, |
| 2196 | 2217 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2197 | 2218 | "FROM v_reports WHERE 1 ", -1); |
| 2198 | 2219 | if(zUserName&&*zUserName){ |
| @@ -2222,12 +2243,13 @@ | ||
| 2222 | 2243 | if(4 == nYear){ |
| 2223 | 2244 | Stmt stWeek = empty_Stmt; |
| 2224 | 2245 | int rowCount = 0; |
| 2225 | 2246 | int total = 0; |
| 2226 | 2247 | 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); | |
| 2229 | 2251 | blob_appendf(&sql, |
| 2230 | 2252 | "SELECT DISTINCT strftime('%%%%W',mtime) AS wk, " |
| 2231 | 2253 | "count(*) AS n " |
| 2232 | 2254 | "FROM v_reports " |
| 2233 | 2255 | "WHERE %Q=substr(date(mtime),1,4) " |
| 2234 | 2256 |
| --- 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 |