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.

stephan 2013-07-16 21:58 UTC stats-report-weekly
Commit 4f5980385bfc8ad743d4c6a1de920973c31436fa
1 file changed +12 -11
+12 -11
--- src/timeline.c
+++ src/timeline.c
@@ -1355,11 +1355,11 @@
13551355
db_multi_exec("%s", blob_str(&sql));
13561356
13571357
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
13581358
if( zYearMonth ){
13591359
blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
1360
- }if( zYearWeek ){
1360
+ }else if( zYearWeek ){
13611361
blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek);
13621362
}else if( zAfter==0 && zBefore==0 && zCirca==0 ){
13631363
blob_appendf(&desc, "%d most recent %ss", n, zEType);
13641364
}else{
13651365
blob_appendf(&desc, "%d %ss", n, zEType);
@@ -1841,11 +1841,11 @@
18411841
/*
18421842
** Helper for stats_report_by_month_year(), which generates a list of
18431843
** week numbers. zTimeframe should be either a timeframe in the form YYYY
18441844
** or YYYY-MM.
18451845
*/
1846
-static void stats_report_output_week_links( char const * zTimeframe){
1846
+static void stats_report_output_week_links(char const * zTimeframe){
18471847
Stmt stWeek = empty_Stmt;
18481848
char yearPart[5] = {0,0,0,0,0};
18491849
memcpy(yearPart, zTimeframe, 4);
18501850
db_prepare(&stWeek,
18511851
"SELECT DISTINCT strftime('%%W',mtime) AS wk, "
@@ -1856,12 +1856,15 @@
18561856
"GROUP BY wk ORDER BY wk",
18571857
strlen(zTimeframe),
18581858
zTimeframe);
18591859
while( SQLITE_ROW == db_step(&stWeek) ){
18601860
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);
18631866
}
18641867
db_finalize(&stWeek);
18651868
}
18661869
18671870
/*
@@ -2062,19 +2065,17 @@
20622065
/*
20632066
** Helper for stats_report_by_month_year(), which generates a list of
20642067
** week numbers. zTimeframe should be either a timeframe in the form YYYY
20652068
** or YYYY-MM.
20662069
*/
2067
-static void stats_report_year_weeks(){
2070
+static void stats_report_year_weeks(char const * zUserName){
20682071
char const * zYear = P("y");
20692072
int nYear = zYear ? strlen(zYear) : 0;
20702073
int i = 0;
20712074
Stmt qYears = empty_Stmt;
20722075
char * zDefaultYear = NULL;
2073
- char const * zUserName = P("user");
20742076
Blob sql = empty_blob;
2075
- if(!zUserName) zUserName = P("u");
20762077
cgi_printf("Select year: ");
20772078
20782079
blob_append(&sql,
20792080
"SELECT DISTINCT substr(date(mtime),1,4) AS y "
20802081
"FROM event WHERE 1 ", -1);
@@ -2135,16 +2136,16 @@
21352136
"<tbody>");
21362137
db_prepare(&stWeek, blob_str(&sql));
21372138
blob_reset(&sql);
21382139
while( SQLITE_ROW == db_step(&stWeek) ){
21392140
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);
21412142
int const graphSize = nPixelsPerEvent * nCount;
21422143
total += nCount;
21432144
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);
21462147
if(zUserName && *zUserName){
21472148
cgi_printf("&u=%t",zUserName);
21482149
}
21492150
cgi_printf("'>%s</a></td>",zWeek);
21502151
@@ -2200,11 +2201,11 @@
22002201
if(0==fossil_strcmp(zView,"byyear")){
22012202
stats_report_by_month_year(0, 0, zUserName);
22022203
}else if(0==fossil_strcmp(zView,"bymonth")){
22032204
stats_report_by_month_year(1, 0, zUserName);
22042205
}else if(0==fossil_strcmp(zView,"byweek")){
2205
- stats_report_year_weeks();
2206
+ stats_report_year_weeks(zUserName);
22062207
}else if(0==fossil_strcmp(zView,"byuser")){
22072208
stats_report_by_user();
22082209
}else{
22092210
@ <h1>Select a report to show:</h1>
22102211
@ <ul>
22112212
--- 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

Keyboard Shortcuts

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