Fossil SCM
Eliminate some unused variables. "int const" -> "const int" and "char const" -> "const char"
Commit
b2640f61d7849fdbfa0f6df92714628bab36b20d
Parent
c41d70dccd14b61…
1 file changed
+22
-25
+22
-25
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1841,11 +1841,11 @@ | ||
| 1841 | 1841 | /* |
| 1842 | 1842 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 1843 | 1843 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 1844 | 1844 | ** or YYYY-MM. |
| 1845 | 1845 | */ |
| 1846 | -static void stats_report_output_week_links(char const * zTimeframe){ | |
| 1846 | +static void stats_report_output_week_links(const char * zTimeframe){ | |
| 1847 | 1847 | Stmt stWeek = empty_Stmt; |
| 1848 | 1848 | char yearPart[5] = {0,0,0,0,0}; |
| 1849 | 1849 | memcpy(yearPart, zTimeframe, 4); |
| 1850 | 1850 | db_prepare(&stWeek, |
| 1851 | 1851 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| @@ -1855,12 +1855,12 @@ | ||
| 1855 | 1855 | "WHERE ym=%Q AND mtime < current_timestamp " |
| 1856 | 1856 | "GROUP BY wk ORDER BY wk", |
| 1857 | 1857 | strlen(zTimeframe), |
| 1858 | 1858 | zTimeframe); |
| 1859 | 1859 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1860 | - char const * zWeek = db_column_text(&stWeek,0); | |
| 1861 | - int const nCount = db_column_int(&stWeek,1); | |
| 1860 | + const char * zWeek = db_column_text(&stWeek,0); | |
| 1861 | + const int nCount = db_column_int(&stWeek,1); | |
| 1862 | 1862 | cgi_printf("<a href='%s/timeline?" |
| 1863 | 1863 | "yw=%t-%t&n=%d'>%s</a>", |
| 1864 | 1864 | g.zTop, yearPart, zWeek, |
| 1865 | 1865 | nCount, zWeek); |
| 1866 | 1866 | } |
| @@ -1874,19 +1874,18 @@ | ||
| 1874 | 1874 | ** then the report is restricted to events created by the named user |
| 1875 | 1875 | ** account. |
| 1876 | 1876 | */ |
| 1877 | 1877 | static void stats_report_by_month_year(char includeMonth, |
| 1878 | 1878 | char includeWeeks, |
| 1879 | - char const * zUserName){ | |
| 1879 | + const char * zUserName){ | |
| 1880 | 1880 | Stmt query = empty_Stmt; |
| 1881 | - int const nPixelsPerEvent = 1; /* for sizing the "graph" part */ | |
| 1882 | 1881 | int nRowNumber = 0; /* current TR number */ |
| 1883 | 1882 | int nEventTotal = 0; /* Total event count */ |
| 1884 | 1883 | int rowClass = 0; /* counter for alternating |
| 1885 | 1884 | row colors */ |
| 1886 | 1885 | Blob sql = empty_blob; /* SQL */ |
| 1887 | - char const * zTimeLabel = includeMonth ? "Year/Month" : "Year"; | |
| 1886 | + const char * zTimeLabel = includeMonth ? "Year/Month" : "Year"; | |
| 1888 | 1887 | char zPrevYear[5] = {0}; /* For keeping track of when |
| 1889 | 1888 | we change years while looping */ |
| 1890 | 1889 | int nEventsPerYear = 0; /* Total event count for the |
| 1891 | 1890 | current year */ |
| 1892 | 1891 | char showYearTotal = 0; /* Flag telling us when to show |
| @@ -1924,20 +1923,20 @@ | ||
| 1924 | 1923 | Run the query twice. The first time we calculate the maximum |
| 1925 | 1924 | number of events for a given row. Maybe someone with better SQL |
| 1926 | 1925 | Fu can re-implement this with a single query. |
| 1927 | 1926 | */ |
| 1928 | 1927 | while( SQLITE_ROW == db_step(&query) ){ |
| 1929 | - int const nCount = db_column_int(&query, 1); | |
| 1928 | + const int nCount = db_column_int(&query, 1); | |
| 1930 | 1929 | if(nCount>nMaxEvents){ |
| 1931 | 1930 | nMaxEvents = nCount; |
| 1932 | 1931 | } |
| 1933 | 1932 | } |
| 1934 | 1933 | db_reset(&query); |
| 1935 | 1934 | 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 | |
| 1935 | + const char * zTimeframe = db_column_text(&query, 0); | |
| 1936 | + const int nCount = db_column_int(&query, 1); | |
| 1937 | + const int nSize = nCount | |
| 1939 | 1938 | ? (int)(100 * nCount / nMaxEvents) |
| 1940 | 1939 | : 1; |
| 1941 | 1940 | showYearTotal = 0; |
| 1942 | 1941 | if(includeMonth){ |
| 1943 | 1942 | /* For Month/year view, add a separator for each distinct year. */ |
| @@ -2025,11 +2024,10 @@ | ||
| 2025 | 2024 | /* |
| 2026 | 2025 | ** Implements the "byuser" view for /stats_report. |
| 2027 | 2026 | */ |
| 2028 | 2027 | static void stats_report_by_user(){ |
| 2029 | 2028 | Stmt query = empty_Stmt; |
| 2030 | - int const nPixelsPerEvent = 1; /* for sizing the "graph" part */ | |
| 2031 | 2029 | int nRowNumber = 0; /* current TR number */ |
| 2032 | 2030 | int nEventTotal = 0; /* Total event count */ |
| 2033 | 2031 | int rowClass = 0; /* counter for alternating |
| 2034 | 2032 | row colors */ |
| 2035 | 2033 | Blob sql = empty_blob; /* SQL */ |
| @@ -2050,20 +2048,20 @@ | ||
| 2050 | 2048 | @ <th>User</th> |
| 2051 | 2049 | @ <th>Events</th> |
| 2052 | 2050 | @ <th width='90%%'><!-- relative commits graph --></th> |
| 2053 | 2051 | @ </tr></thead><tbody> |
| 2054 | 2052 | while( SQLITE_ROW == db_step(&query) ){ |
| 2055 | - int const nCount = db_column_int(&query, 1); | |
| 2053 | + const int nCount = db_column_int(&query, 1); | |
| 2056 | 2054 | if(nCount>nMaxEvents){ |
| 2057 | 2055 | nMaxEvents = nCount; |
| 2058 | 2056 | } |
| 2059 | 2057 | } |
| 2060 | 2058 | db_reset(&query); |
| 2061 | 2059 | 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 | |
| 2060 | + const char * zUser = db_column_text(&query, 0); | |
| 2061 | + const int nCount = db_column_int(&query, 1); | |
| 2062 | + const int nSize = nCount | |
| 2065 | 2063 | ? (int)(100 * nCount / nMaxEvents) |
| 2066 | 2064 | : 0; |
| 2067 | 2065 | if(!nCount) continue /* arguable! Possible? */; |
| 2068 | 2066 | rowClass = ++nRowNumber % 2; |
| 2069 | 2067 | nEventTotal += nCount; |
| @@ -2090,12 +2088,12 @@ | ||
| 2090 | 2088 | /* |
| 2091 | 2089 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 2092 | 2090 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 2093 | 2091 | ** or YYYY-MM. |
| 2094 | 2092 | */ |
| 2095 | -static void stats_report_year_weeks(char const * zUserName){ | |
| 2096 | - char const * zYear = P("y"); | |
| 2093 | +static void stats_report_year_weeks(const char * zUserName){ | |
| 2094 | + const char * zYear = P("y"); | |
| 2097 | 2095 | int nYear = zYear ? strlen(zYear) : 0; |
| 2098 | 2096 | int i = 0; |
| 2099 | 2097 | Stmt qYears = empty_Stmt; |
| 2100 | 2098 | char * zDefaultYear = NULL; |
| 2101 | 2099 | Blob sql = empty_blob; |
| @@ -2111,11 +2109,11 @@ | ||
| 2111 | 2109 | } |
| 2112 | 2110 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2113 | 2111 | db_prepare(&qYears, blob_str(&sql)); |
| 2114 | 2112 | blob_reset(&sql); |
| 2115 | 2113 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2116 | - char const * zT = db_column_text(&qYears, 0); | |
| 2114 | + const char * zT = db_column_text(&qYears, 0); | |
| 2117 | 2115 | if( i++ ){ |
| 2118 | 2116 | cgi_printf(" "); |
| 2119 | 2117 | } |
| 2120 | 2118 | cgi_printf("<a href='?view=byweek&y=%s", zT); |
| 2121 | 2119 | if(zUserName && *zUserName){ |
| @@ -2129,11 +2127,10 @@ | ||
| 2129 | 2127 | zDefaultYear = db_text("????", "SELECT strftime('%%Y')"); |
| 2130 | 2128 | zYear = zDefaultYear; |
| 2131 | 2129 | nYear = 4; |
| 2132 | 2130 | } |
| 2133 | 2131 | if(4 == nYear){ |
| 2134 | - int const nPixelsPerEvent = 3; /* for sizing the "graph" part */ | |
| 2135 | 2132 | Stmt stWeek = empty_Stmt; |
| 2136 | 2133 | int rowCount = 0; |
| 2137 | 2134 | int total = 0; |
| 2138 | 2135 | Blob header = empty_blob; |
| 2139 | 2136 | blob_appendf(&header, "Timeline events for the calendar weeks " |
| @@ -2162,20 +2159,20 @@ | ||
| 2162 | 2159 | "</tr></thead>" |
| 2163 | 2160 | "<tbody>"); |
| 2164 | 2161 | db_prepare(&stWeek, blob_str(&sql)); |
| 2165 | 2162 | blob_reset(&sql); |
| 2166 | 2163 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2167 | - int const nCount = db_column_int(&stWeek, 1); | |
| 2164 | + const int nCount = db_column_int(&stWeek, 1); | |
| 2168 | 2165 | if(nCount>nMaxEvents){ |
| 2169 | 2166 | nMaxEvents = nCount; |
| 2170 | 2167 | } |
| 2171 | 2168 | } |
| 2172 | 2169 | db_reset(&stWeek); |
| 2173 | 2170 | 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 | |
| 2171 | + const char * zWeek = db_column_text(&stWeek,0); | |
| 2172 | + const int nCount = db_column_int(&stWeek,1); | |
| 2173 | + const int nSize = nCount | |
| 2177 | 2174 | ? (int)(100 * nCount / nMaxEvents) |
| 2178 | 2175 | : 0; |
| 2179 | 2176 | total += nCount; |
| 2180 | 2177 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2181 | 2178 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| @@ -2215,12 +2212,12 @@ | ||
| 2215 | 2212 | ** view=REPORT_NAME Valid values: bymonth, byyear, byuser |
| 2216 | 2213 | ** user=NAME Restricts statistics to the given user |
| 2217 | 2214 | */ |
| 2218 | 2215 | void stats_report_page(){ |
| 2219 | 2216 | HQuery url; /* URL for various branch links */ |
| 2220 | - char const * zView = P("view"); /* Which view/report to show. */ | |
| 2221 | - char const *zUserName = P("user"); | |
| 2217 | + const char * zView = P("view"); /* Which view/report to show. */ | |
| 2218 | + const char *zUserName = P("user"); | |
| 2222 | 2219 | if(!zUserName) zUserName = P("u"); |
| 2223 | 2220 | url_initialize(&url, "stats_report"); |
| 2224 | 2221 | |
| 2225 | 2222 | if(zUserName && *zUserName){ |
| 2226 | 2223 | url_add_parameter(&url,"user", zUserName); |
| 2227 | 2224 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1841,11 +1841,11 @@ | |
| 1841 | /* |
| 1842 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 1843 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 1844 | ** or YYYY-MM. |
| 1845 | */ |
| 1846 | static void stats_report_output_week_links(char const * zTimeframe){ |
| 1847 | Stmt stWeek = empty_Stmt; |
| 1848 | char yearPart[5] = {0,0,0,0,0}; |
| 1849 | memcpy(yearPart, zTimeframe, 4); |
| 1850 | db_prepare(&stWeek, |
| 1851 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| @@ -1855,12 +1855,12 @@ | |
| 1855 | "WHERE ym=%Q AND mtime < current_timestamp " |
| 1856 | "GROUP BY wk ORDER BY wk", |
| 1857 | strlen(zTimeframe), |
| 1858 | zTimeframe); |
| 1859 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1860 | char const * zWeek = db_column_text(&stWeek,0); |
| 1861 | int const nCount = db_column_int(&stWeek,1); |
| 1862 | cgi_printf("<a href='%s/timeline?" |
| 1863 | "yw=%t-%t&n=%d'>%s</a>", |
| 1864 | g.zTop, yearPart, zWeek, |
| 1865 | nCount, zWeek); |
| 1866 | } |
| @@ -1874,19 +1874,18 @@ | |
| 1874 | ** then the report is restricted to events created by the named user |
| 1875 | ** account. |
| 1876 | */ |
| 1877 | static void stats_report_by_month_year(char includeMonth, |
| 1878 | char includeWeeks, |
| 1879 | char const * zUserName){ |
| 1880 | Stmt query = empty_Stmt; |
| 1881 | int const nPixelsPerEvent = 1; /* for sizing the "graph" part */ |
| 1882 | int nRowNumber = 0; /* current TR number */ |
| 1883 | int nEventTotal = 0; /* Total event count */ |
| 1884 | int rowClass = 0; /* counter for alternating |
| 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 |
| @@ -1924,20 +1923,20 @@ | |
| 1924 | Run the query twice. The first time we calculate the maximum |
| 1925 | number of events for a given row. Maybe someone with better SQL |
| 1926 | Fu can re-implement this with a single query. |
| 1927 | */ |
| 1928 | while( SQLITE_ROW == db_step(&query) ){ |
| 1929 | int const nCount = db_column_int(&query, 1); |
| 1930 | if(nCount>nMaxEvents){ |
| 1931 | nMaxEvents = nCount; |
| 1932 | } |
| 1933 | } |
| 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. */ |
| @@ -2025,11 +2024,10 @@ | |
| 2025 | /* |
| 2026 | ** Implements the "byuser" view for /stats_report. |
| 2027 | */ |
| 2028 | static void stats_report_by_user(){ |
| 2029 | Stmt query = empty_Stmt; |
| 2030 | int const nPixelsPerEvent = 1; /* for sizing the "graph" part */ |
| 2031 | int nRowNumber = 0; /* current TR number */ |
| 2032 | int nEventTotal = 0; /* Total event count */ |
| 2033 | int rowClass = 0; /* counter for alternating |
| 2034 | row colors */ |
| 2035 | Blob sql = empty_blob; /* SQL */ |
| @@ -2050,20 +2048,20 @@ | |
| 2050 | @ <th>User</th> |
| 2051 | @ <th>Events</th> |
| 2052 | @ <th width='90%%'><!-- relative commits graph --></th> |
| 2053 | @ </tr></thead><tbody> |
| 2054 | while( SQLITE_ROW == db_step(&query) ){ |
| 2055 | int const nCount = db_column_int(&query, 1); |
| 2056 | if(nCount>nMaxEvents){ |
| 2057 | nMaxEvents = nCount; |
| 2058 | } |
| 2059 | } |
| 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; |
| @@ -2090,12 +2088,12 @@ | |
| 2090 | /* |
| 2091 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 2092 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 2093 | ** or YYYY-MM. |
| 2094 | */ |
| 2095 | static void stats_report_year_weeks(char const * zUserName){ |
| 2096 | char const * zYear = P("y"); |
| 2097 | int nYear = zYear ? strlen(zYear) : 0; |
| 2098 | int i = 0; |
| 2099 | Stmt qYears = empty_Stmt; |
| 2100 | char * zDefaultYear = NULL; |
| 2101 | Blob sql = empty_blob; |
| @@ -2111,11 +2109,11 @@ | |
| 2111 | } |
| 2112 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2113 | db_prepare(&qYears, blob_str(&sql)); |
| 2114 | blob_reset(&sql); |
| 2115 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2116 | char const * zT = db_column_text(&qYears, 0); |
| 2117 | if( i++ ){ |
| 2118 | cgi_printf(" "); |
| 2119 | } |
| 2120 | cgi_printf("<a href='?view=byweek&y=%s", zT); |
| 2121 | if(zUserName && *zUserName){ |
| @@ -2129,11 +2127,10 @@ | |
| 2129 | zDefaultYear = db_text("????", "SELECT strftime('%%Y')"); |
| 2130 | zYear = zDefaultYear; |
| 2131 | nYear = 4; |
| 2132 | } |
| 2133 | if(4 == nYear){ |
| 2134 | int const nPixelsPerEvent = 3; /* for sizing the "graph" part */ |
| 2135 | Stmt stWeek = empty_Stmt; |
| 2136 | int rowCount = 0; |
| 2137 | int total = 0; |
| 2138 | Blob header = empty_blob; |
| 2139 | blob_appendf(&header, "Timeline events for the calendar weeks " |
| @@ -2162,20 +2159,20 @@ | |
| 2162 | "</tr></thead>" |
| 2163 | "<tbody>"); |
| 2164 | db_prepare(&stWeek, blob_str(&sql)); |
| 2165 | blob_reset(&sql); |
| 2166 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2167 | int const nCount = db_column_int(&stWeek, 1); |
| 2168 | if(nCount>nMaxEvents){ |
| 2169 | nMaxEvents = nCount; |
| 2170 | } |
| 2171 | } |
| 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", |
| @@ -2215,12 +2212,12 @@ | |
| 2215 | ** view=REPORT_NAME Valid values: bymonth, byyear, byuser |
| 2216 | ** user=NAME Restricts statistics to the given user |
| 2217 | */ |
| 2218 | void stats_report_page(){ |
| 2219 | HQuery url; /* URL for various branch links */ |
| 2220 | char const * zView = P("view"); /* Which view/report to show. */ |
| 2221 | char const *zUserName = P("user"); |
| 2222 | if(!zUserName) zUserName = P("u"); |
| 2223 | url_initialize(&url, "stats_report"); |
| 2224 | |
| 2225 | if(zUserName && *zUserName){ |
| 2226 | url_add_parameter(&url,"user", zUserName); |
| 2227 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1841,11 +1841,11 @@ | |
| 1841 | /* |
| 1842 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 1843 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 1844 | ** or YYYY-MM. |
| 1845 | */ |
| 1846 | static void stats_report_output_week_links(const char * zTimeframe){ |
| 1847 | Stmt stWeek = empty_Stmt; |
| 1848 | char yearPart[5] = {0,0,0,0,0}; |
| 1849 | memcpy(yearPart, zTimeframe, 4); |
| 1850 | db_prepare(&stWeek, |
| 1851 | "SELECT DISTINCT strftime('%%W',mtime) AS wk, " |
| @@ -1855,12 +1855,12 @@ | |
| 1855 | "WHERE ym=%Q AND mtime < current_timestamp " |
| 1856 | "GROUP BY wk ORDER BY wk", |
| 1857 | strlen(zTimeframe), |
| 1858 | zTimeframe); |
| 1859 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1860 | const char * zWeek = db_column_text(&stWeek,0); |
| 1861 | const int nCount = db_column_int(&stWeek,1); |
| 1862 | cgi_printf("<a href='%s/timeline?" |
| 1863 | "yw=%t-%t&n=%d'>%s</a>", |
| 1864 | g.zTop, yearPart, zWeek, |
| 1865 | nCount, zWeek); |
| 1866 | } |
| @@ -1874,19 +1874,18 @@ | |
| 1874 | ** then the report is restricted to events created by the named user |
| 1875 | ** account. |
| 1876 | */ |
| 1877 | static void stats_report_by_month_year(char includeMonth, |
| 1878 | char includeWeeks, |
| 1879 | const char * zUserName){ |
| 1880 | Stmt query = empty_Stmt; |
| 1881 | int nRowNumber = 0; /* current TR number */ |
| 1882 | int nEventTotal = 0; /* Total event count */ |
| 1883 | int rowClass = 0; /* counter for alternating |
| 1884 | row colors */ |
| 1885 | Blob sql = empty_blob; /* SQL */ |
| 1886 | const char * zTimeLabel = includeMonth ? "Year/Month" : "Year"; |
| 1887 | char zPrevYear[5] = {0}; /* For keeping track of when |
| 1888 | we change years while looping */ |
| 1889 | int nEventsPerYear = 0; /* Total event count for the |
| 1890 | current year */ |
| 1891 | char showYearTotal = 0; /* Flag telling us when to show |
| @@ -1924,20 +1923,20 @@ | |
| 1923 | Run the query twice. The first time we calculate the maximum |
| 1924 | number of events for a given row. Maybe someone with better SQL |
| 1925 | Fu can re-implement this with a single query. |
| 1926 | */ |
| 1927 | while( SQLITE_ROW == db_step(&query) ){ |
| 1928 | const int nCount = db_column_int(&query, 1); |
| 1929 | if(nCount>nMaxEvents){ |
| 1930 | nMaxEvents = nCount; |
| 1931 | } |
| 1932 | } |
| 1933 | db_reset(&query); |
| 1934 | while( SQLITE_ROW == db_step(&query) ){ |
| 1935 | const char * zTimeframe = db_column_text(&query, 0); |
| 1936 | const int nCount = db_column_int(&query, 1); |
| 1937 | const int nSize = nCount |
| 1938 | ? (int)(100 * nCount / nMaxEvents) |
| 1939 | : 1; |
| 1940 | showYearTotal = 0; |
| 1941 | if(includeMonth){ |
| 1942 | /* For Month/year view, add a separator for each distinct year. */ |
| @@ -2025,11 +2024,10 @@ | |
| 2024 | /* |
| 2025 | ** Implements the "byuser" view for /stats_report. |
| 2026 | */ |
| 2027 | static void stats_report_by_user(){ |
| 2028 | Stmt query = empty_Stmt; |
| 2029 | int nRowNumber = 0; /* current TR number */ |
| 2030 | int nEventTotal = 0; /* Total event count */ |
| 2031 | int rowClass = 0; /* counter for alternating |
| 2032 | row colors */ |
| 2033 | Blob sql = empty_blob; /* SQL */ |
| @@ -2050,20 +2048,20 @@ | |
| 2048 | @ <th>User</th> |
| 2049 | @ <th>Events</th> |
| 2050 | @ <th width='90%%'><!-- relative commits graph --></th> |
| 2051 | @ </tr></thead><tbody> |
| 2052 | while( SQLITE_ROW == db_step(&query) ){ |
| 2053 | const int nCount = db_column_int(&query, 1); |
| 2054 | if(nCount>nMaxEvents){ |
| 2055 | nMaxEvents = nCount; |
| 2056 | } |
| 2057 | } |
| 2058 | db_reset(&query); |
| 2059 | while( SQLITE_ROW == db_step(&query) ){ |
| 2060 | const char * zUser = db_column_text(&query, 0); |
| 2061 | const int nCount = db_column_int(&query, 1); |
| 2062 | const int nSize = nCount |
| 2063 | ? (int)(100 * nCount / nMaxEvents) |
| 2064 | : 0; |
| 2065 | if(!nCount) continue /* arguable! Possible? */; |
| 2066 | rowClass = ++nRowNumber % 2; |
| 2067 | nEventTotal += nCount; |
| @@ -2090,12 +2088,12 @@ | |
| 2088 | /* |
| 2089 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 2090 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 2091 | ** or YYYY-MM. |
| 2092 | */ |
| 2093 | static void stats_report_year_weeks(const char * zUserName){ |
| 2094 | const char * zYear = P("y"); |
| 2095 | int nYear = zYear ? strlen(zYear) : 0; |
| 2096 | int i = 0; |
| 2097 | Stmt qYears = empty_Stmt; |
| 2098 | char * zDefaultYear = NULL; |
| 2099 | Blob sql = empty_blob; |
| @@ -2111,11 +2109,11 @@ | |
| 2109 | } |
| 2110 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2111 | db_prepare(&qYears, blob_str(&sql)); |
| 2112 | blob_reset(&sql); |
| 2113 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2114 | const char * zT = db_column_text(&qYears, 0); |
| 2115 | if( i++ ){ |
| 2116 | cgi_printf(" "); |
| 2117 | } |
| 2118 | cgi_printf("<a href='?view=byweek&y=%s", zT); |
| 2119 | if(zUserName && *zUserName){ |
| @@ -2129,11 +2127,10 @@ | |
| 2127 | zDefaultYear = db_text("????", "SELECT strftime('%%Y')"); |
| 2128 | zYear = zDefaultYear; |
| 2129 | nYear = 4; |
| 2130 | } |
| 2131 | if(4 == nYear){ |
| 2132 | Stmt stWeek = empty_Stmt; |
| 2133 | int rowCount = 0; |
| 2134 | int total = 0; |
| 2135 | Blob header = empty_blob; |
| 2136 | blob_appendf(&header, "Timeline events for the calendar weeks " |
| @@ -2162,20 +2159,20 @@ | |
| 2159 | "</tr></thead>" |
| 2160 | "<tbody>"); |
| 2161 | db_prepare(&stWeek, blob_str(&sql)); |
| 2162 | blob_reset(&sql); |
| 2163 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2164 | const int nCount = db_column_int(&stWeek, 1); |
| 2165 | if(nCount>nMaxEvents){ |
| 2166 | nMaxEvents = nCount; |
| 2167 | } |
| 2168 | } |
| 2169 | db_reset(&stWeek); |
| 2170 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2171 | const char * zWeek = db_column_text(&stWeek,0); |
| 2172 | const int nCount = db_column_int(&stWeek,1); |
| 2173 | const int nSize = nCount |
| 2174 | ? (int)(100 * nCount / nMaxEvents) |
| 2175 | : 0; |
| 2176 | total += nCount; |
| 2177 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2178 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| @@ -2215,12 +2212,12 @@ | |
| 2212 | ** view=REPORT_NAME Valid values: bymonth, byyear, byuser |
| 2213 | ** user=NAME Restricts statistics to the given user |
| 2214 | */ |
| 2215 | void stats_report_page(){ |
| 2216 | HQuery url; /* URL for various branch links */ |
| 2217 | const char * zView = P("view"); /* Which view/report to show. */ |
| 2218 | const char *zUserName = P("user"); |
| 2219 | if(!zUserName) zUserName = P("u"); |
| 2220 | url_initialize(&url, "stats_report"); |
| 2221 | |
| 2222 | if(zUserName && *zUserName){ |
| 2223 | url_add_parameter(&url,"user", zUserName); |
| 2224 |