Fossil SCM
Added n=### to /timeline links from /stats_report byweek view. Added a missing else in /timeline?yw=... which caused too many search clauses and too much header text.
Commit
4f5980385bfc8ad743d4c6a1de920973c31436fa
Parent
7eeaf16e7252699…
1 file changed
+12
-11
+12
-11
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1355,11 +1355,11 @@ | ||
| 1355 | 1355 | db_multi_exec("%s", blob_str(&sql)); |
| 1356 | 1356 | |
| 1357 | 1357 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1358 | 1358 | if( zYearMonth ){ |
| 1359 | 1359 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1360 | - }if( zYearWeek ){ | |
| 1360 | + }else if( zYearWeek ){ | |
| 1361 | 1361 | blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); |
| 1362 | 1362 | }else if( zAfter==0 && zBefore==0 && zCirca==0 ){ |
| 1363 | 1363 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1364 | 1364 | }else{ |
| 1365 | 1365 | blob_appendf(&desc, "%d %ss", n, zEType); |
| @@ -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(char const * 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, " |
| @@ -1856,12 +1856,15 @@ | ||
| 1856 | 1856 | "GROUP BY wk ORDER BY wk", |
| 1857 | 1857 | strlen(zTimeframe), |
| 1858 | 1858 | zTimeframe); |
| 1859 | 1859 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 1860 | 1860 | char const * zWeek = db_column_text(&stWeek,0); |
| 1861 | - @ <a href='%s(g.zTop)/timeline?yw=%t(yearPart)-%t(zWeek)'> | |
| 1862 | - @ %s(zWeek)</a> | |
| 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); | |
| 1863 | 1866 | } |
| 1864 | 1867 | db_finalize(&stWeek); |
| 1865 | 1868 | } |
| 1866 | 1869 | |
| 1867 | 1870 | /* |
| @@ -2062,19 +2065,17 @@ | ||
| 2062 | 2065 | /* |
| 2063 | 2066 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 2064 | 2067 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 2065 | 2068 | ** or YYYY-MM. |
| 2066 | 2069 | */ |
| 2067 | -static void stats_report_year_weeks(){ | |
| 2070 | +static void stats_report_year_weeks(char const * zUserName){ | |
| 2068 | 2071 | char const * zYear = P("y"); |
| 2069 | 2072 | int nYear = zYear ? strlen(zYear) : 0; |
| 2070 | 2073 | int i = 0; |
| 2071 | 2074 | Stmt qYears = empty_Stmt; |
| 2072 | 2075 | char * zDefaultYear = NULL; |
| 2073 | - char const * zUserName = P("user"); | |
| 2074 | 2076 | Blob sql = empty_blob; |
| 2075 | - if(!zUserName) zUserName = P("u"); | |
| 2076 | 2077 | cgi_printf("Select year: "); |
| 2077 | 2078 | |
| 2078 | 2079 | blob_append(&sql, |
| 2079 | 2080 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2080 | 2081 | "FROM event WHERE 1 ", -1); |
| @@ -2135,16 +2136,16 @@ | ||
| 2135 | 2136 | "<tbody>"); |
| 2136 | 2137 | db_prepare(&stWeek, blob_str(&sql)); |
| 2137 | 2138 | blob_reset(&sql); |
| 2138 | 2139 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2139 | 2140 | char const * zWeek = db_column_text(&stWeek,0); |
| 2140 | - int nCount = db_column_int(&stWeek,1); | |
| 2141 | + int const nCount = db_column_int(&stWeek,1); | |
| 2141 | 2142 | int const graphSize = nPixelsPerEvent * nCount; |
| 2142 | 2143 | total += nCount; |
| 2143 | 2144 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2144 | - cgi_printf("<td><a href='%s/timeline?yw=%t-%s", | |
| 2145 | - g.zTop, zYear, zWeek); | |
| 2145 | + cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", | |
| 2146 | + g.zTop, zYear, zWeek, nCount); | |
| 2146 | 2147 | if(zUserName && *zUserName){ |
| 2147 | 2148 | cgi_printf("&u=%t",zUserName); |
| 2148 | 2149 | } |
| 2149 | 2150 | cgi_printf("'>%s</a></td>",zWeek); |
| 2150 | 2151 | |
| @@ -2200,11 +2201,11 @@ | ||
| 2200 | 2201 | if(0==fossil_strcmp(zView,"byyear")){ |
| 2201 | 2202 | stats_report_by_month_year(0, 0, zUserName); |
| 2202 | 2203 | }else if(0==fossil_strcmp(zView,"bymonth")){ |
| 2203 | 2204 | stats_report_by_month_year(1, 0, zUserName); |
| 2204 | 2205 | }else if(0==fossil_strcmp(zView,"byweek")){ |
| 2205 | - stats_report_year_weeks(); | |
| 2206 | + stats_report_year_weeks(zUserName); | |
| 2206 | 2207 | }else if(0==fossil_strcmp(zView,"byuser")){ |
| 2207 | 2208 | stats_report_by_user(); |
| 2208 | 2209 | }else{ |
| 2209 | 2210 | @ <h1>Select a report to show:</h1> |
| 2210 | 2211 | @ <ul> |
| 2211 | 2212 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1355,11 +1355,11 @@ | |
| 1355 | db_multi_exec("%s", blob_str(&sql)); |
| 1356 | |
| 1357 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1358 | if( zYearMonth ){ |
| 1359 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1360 | }if( zYearWeek ){ |
| 1361 | blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); |
| 1362 | }else if( zAfter==0 && zBefore==0 && zCirca==0 ){ |
| 1363 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1364 | }else{ |
| 1365 | blob_appendf(&desc, "%d %ss", n, zEType); |
| @@ -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, " |
| @@ -1856,12 +1856,15 @@ | |
| 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 | @ <a href='%s(g.zTop)/timeline?yw=%t(yearPart)-%t(zWeek)'> |
| 1862 | @ %s(zWeek)</a> |
| 1863 | } |
| 1864 | db_finalize(&stWeek); |
| 1865 | } |
| 1866 | |
| 1867 | /* |
| @@ -2062,19 +2065,17 @@ | |
| 2062 | /* |
| 2063 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 2064 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 2065 | ** or YYYY-MM. |
| 2066 | */ |
| 2067 | static void stats_report_year_weeks(){ |
| 2068 | char const * zYear = P("y"); |
| 2069 | int nYear = zYear ? strlen(zYear) : 0; |
| 2070 | int i = 0; |
| 2071 | Stmt qYears = empty_Stmt; |
| 2072 | char * zDefaultYear = NULL; |
| 2073 | char const * zUserName = P("user"); |
| 2074 | Blob sql = empty_blob; |
| 2075 | if(!zUserName) zUserName = P("u"); |
| 2076 | cgi_printf("Select year: "); |
| 2077 | |
| 2078 | blob_append(&sql, |
| 2079 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2080 | "FROM event WHERE 1 ", -1); |
| @@ -2135,16 +2136,16 @@ | |
| 2135 | "<tbody>"); |
| 2136 | db_prepare(&stWeek, blob_str(&sql)); |
| 2137 | blob_reset(&sql); |
| 2138 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2139 | char const * zWeek = db_column_text(&stWeek,0); |
| 2140 | int nCount = db_column_int(&stWeek,1); |
| 2141 | int const graphSize = nPixelsPerEvent * nCount; |
| 2142 | total += nCount; |
| 2143 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2144 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s", |
| 2145 | g.zTop, zYear, zWeek); |
| 2146 | if(zUserName && *zUserName){ |
| 2147 | cgi_printf("&u=%t",zUserName); |
| 2148 | } |
| 2149 | cgi_printf("'>%s</a></td>",zWeek); |
| 2150 | |
| @@ -2200,11 +2201,11 @@ | |
| 2200 | if(0==fossil_strcmp(zView,"byyear")){ |
| 2201 | stats_report_by_month_year(0, 0, zUserName); |
| 2202 | }else if(0==fossil_strcmp(zView,"bymonth")){ |
| 2203 | stats_report_by_month_year(1, 0, zUserName); |
| 2204 | }else if(0==fossil_strcmp(zView,"byweek")){ |
| 2205 | stats_report_year_weeks(); |
| 2206 | }else if(0==fossil_strcmp(zView,"byuser")){ |
| 2207 | stats_report_by_user(); |
| 2208 | }else{ |
| 2209 | @ <h1>Select a report to show:</h1> |
| 2210 | @ <ul> |
| 2211 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1355,11 +1355,11 @@ | |
| 1355 | db_multi_exec("%s", blob_str(&sql)); |
| 1356 | |
| 1357 | n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/"); |
| 1358 | if( zYearMonth ){ |
| 1359 | blob_appendf(&desc, "%s events for %h", zEType, zYearMonth); |
| 1360 | }else if( zYearWeek ){ |
| 1361 | blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek); |
| 1362 | }else if( zAfter==0 && zBefore==0 && zCirca==0 ){ |
| 1363 | blob_appendf(&desc, "%d most recent %ss", n, zEType); |
| 1364 | }else{ |
| 1365 | blob_appendf(&desc, "%d %ss", n, zEType); |
| @@ -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, " |
| @@ -1856,12 +1856,15 @@ | |
| 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 | } |
| 1867 | db_finalize(&stWeek); |
| 1868 | } |
| 1869 | |
| 1870 | /* |
| @@ -2062,19 +2065,17 @@ | |
| 2065 | /* |
| 2066 | ** Helper for stats_report_by_month_year(), which generates a list of |
| 2067 | ** week numbers. zTimeframe should be either a timeframe in the form YYYY |
| 2068 | ** or YYYY-MM. |
| 2069 | */ |
| 2070 | static void stats_report_year_weeks(char const * zUserName){ |
| 2071 | char const * zYear = P("y"); |
| 2072 | int nYear = zYear ? strlen(zYear) : 0; |
| 2073 | int i = 0; |
| 2074 | Stmt qYears = empty_Stmt; |
| 2075 | char * zDefaultYear = NULL; |
| 2076 | Blob sql = empty_blob; |
| 2077 | cgi_printf("Select year: "); |
| 2078 | |
| 2079 | blob_append(&sql, |
| 2080 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2081 | "FROM event WHERE 1 ", -1); |
| @@ -2135,16 +2136,16 @@ | |
| 2136 | "<tbody>"); |
| 2137 | db_prepare(&stWeek, blob_str(&sql)); |
| 2138 | blob_reset(&sql); |
| 2139 | while( SQLITE_ROW == db_step(&stWeek) ){ |
| 2140 | char const * zWeek = db_column_text(&stWeek,0); |
| 2141 | int const nCount = db_column_int(&stWeek,1); |
| 2142 | int const graphSize = nPixelsPerEvent * nCount; |
| 2143 | total += nCount; |
| 2144 | cgi_printf("<tr class='row%d'>", ++rowCount % 2 ); |
| 2145 | cgi_printf("<td><a href='%s/timeline?yw=%t-%s&n=%d", |
| 2146 | g.zTop, zYear, zWeek, nCount); |
| 2147 | if(zUserName && *zUserName){ |
| 2148 | cgi_printf("&u=%t",zUserName); |
| 2149 | } |
| 2150 | cgi_printf("'>%s</a></td>",zWeek); |
| 2151 | |
| @@ -2200,11 +2201,11 @@ | |
| 2201 | if(0==fossil_strcmp(zView,"byyear")){ |
| 2202 | stats_report_by_month_year(0, 0, zUserName); |
| 2203 | }else if(0==fossil_strcmp(zView,"bymonth")){ |
| 2204 | stats_report_by_month_year(1, 0, zUserName); |
| 2205 | }else if(0==fossil_strcmp(zView,"byweek")){ |
| 2206 | stats_report_year_weeks(zUserName); |
| 2207 | }else if(0==fossil_strcmp(zView,"byuser")){ |
| 2208 | stats_report_by_user(); |
| 2209 | }else{ |
| 2210 | @ <h1>Select a report to show:</h1> |
| 2211 | @ <ul> |
| 2212 |