Fossil SCM
/reports byweek fix: the currently selected year is now propagated across the event-type links.
Commit
cba6bbf89c45987a03cf758e971f43d5787500ba
Parent
9b1932f00e45c2c…
1 file changed
+25
-10
+25
-10
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -2077,16 +2077,24 @@ | ||
| 2077 | 2077 | } |
| 2078 | 2078 | |
| 2079 | 2079 | /* |
| 2080 | 2080 | ** A helper for the /reports family of pages which prints out a menu |
| 2081 | 2081 | ** of links for the various type=XXX flags. zCurrentViewName must be |
| 2082 | -** the name/value of the 'view' parameter which is in effect at | |
| 2083 | -** the time this is called. e.g. if called from the 'byuser' view | |
| 2084 | -** then zCurrentViewName must be "byuser". | |
| 2085 | -*/ | |
| 2086 | -static void stats_report_event_types_menu(char const * zCurrentViewName){ | |
| 2087 | - char * zTop = mprintf("%s/reports?view=%s", g.zTop, zCurrentViewName); | |
| 2082 | +** the name/value of the 'view' parameter which is in effect at the | |
| 2083 | +** time this is called. e.g. if called from the 'byuser' view then | |
| 2084 | +** zCurrentViewName must be "byuser". Any URL parameters which need to | |
| 2085 | +** be added to the generated URLs should be passed in zParam. The | |
| 2086 | +** caller is expected to have already encoded any zParam in the %T or | |
| 2087 | +** %t encoding. */ | |
| 2088 | +static void stats_report_event_types_menu(char const * zCurrentViewName, | |
| 2089 | + char const * zParam){ | |
| 2090 | + char * zTop; | |
| 2091 | + if(zParam && !*zParam){ | |
| 2092 | + zParam = NULL; | |
| 2093 | + } | |
| 2094 | + zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName, | |
| 2095 | + zParam ? "&" : "", zParam); | |
| 2088 | 2096 | cgi_printf("<div>"); |
| 2089 | 2097 | cgi_printf("<span>Event types:</span> "); |
| 2090 | 2098 | if('*' == statsReportType){ |
| 2091 | 2099 | cgi_printf(" <strong>all</strong>", zTop); |
| 2092 | 2100 | }else{ |
| @@ -2173,11 +2181,11 @@ | ||
| 2173 | 2181 | int nMaxEvents = 1; /* for calculating length of graph |
| 2174 | 2182 | bars. */ |
| 2175 | 2183 | int iterations = 0; /* number of weeks/months we iterate |
| 2176 | 2184 | over */ |
| 2177 | 2185 | stats_report_init_view(); |
| 2178 | - stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear" ); | |
| 2186 | + stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear", NULL ); | |
| 2179 | 2187 | blob_appendf(&header, "Timeline Events (%s) by year%s", |
| 2180 | 2188 | stats_report_label_for_type(), |
| 2181 | 2189 | (includeMonth ? "/month" : "")); |
| 2182 | 2190 | blob_appendf(&sql, |
| 2183 | 2191 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| @@ -2324,11 +2332,11 @@ | ||
| 2324 | 2332 | row colors */ |
| 2325 | 2333 | Blob sql = empty_blob; /* SQL */ |
| 2326 | 2334 | int nMaxEvents = 1; /* max number of events for |
| 2327 | 2335 | all rows. */ |
| 2328 | 2336 | stats_report_init_view(); |
| 2329 | - stats_report_event_types_menu("byuser"); | |
| 2337 | + stats_report_event_types_menu("byuser", NULL); | |
| 2330 | 2338 | blob_append(&sql, |
| 2331 | 2339 | "SELECT user, " |
| 2332 | 2340 | "COUNT(*) AS eventCount " |
| 2333 | 2341 | "FROM v_reports " |
| 2334 | 2342 | "GROUP BY user ORDER BY eventCount DESC", |
| @@ -2395,21 +2403,28 @@ | ||
| 2395 | 2403 | Blob sql = empty_blob; |
| 2396 | 2404 | int nMaxEvents = 1; /* max number of events for |
| 2397 | 2405 | all rows. */ |
| 2398 | 2406 | int iterations = 0; /* # of active time periods. */ |
| 2399 | 2407 | stats_report_init_view(); |
| 2400 | - stats_report_event_types_menu("byweek"); | |
| 2401 | - cgi_printf("Select year: "); | |
| 2408 | + if(4==nYear){ | |
| 2409 | + Blob urlParams = empty_blob; | |
| 2410 | + blob_appendf(&urlParams, "y=%T", zYear); | |
| 2411 | + stats_report_event_types_menu("byweek", blob_str(&urlParams)); | |
| 2412 | + blob_reset(&urlParams); | |
| 2413 | + }else{ | |
| 2414 | + stats_report_event_types_menu("byweek", NULL); | |
| 2415 | + } | |
| 2402 | 2416 | blob_append(&sql, |
| 2403 | 2417 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2404 | 2418 | "FROM v_reports WHERE 1 ", -1); |
| 2405 | 2419 | if(zUserName&&*zUserName){ |
| 2406 | 2420 | blob_appendf(&sql,"AND user=%Q ", zUserName); |
| 2407 | 2421 | } |
| 2408 | 2422 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2409 | 2423 | db_prepare(&qYears, blob_str(&sql)); |
| 2410 | 2424 | blob_reset(&sql); |
| 2425 | + cgi_printf("Select year: "); | |
| 2411 | 2426 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2412 | 2427 | const char * zT = db_column_text(&qYears, 0); |
| 2413 | 2428 | if( i++ ){ |
| 2414 | 2429 | cgi_printf(" "); |
| 2415 | 2430 | } |
| 2416 | 2431 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2077,16 +2077,24 @@ | |
| 2077 | } |
| 2078 | |
| 2079 | /* |
| 2080 | ** A helper for the /reports family of pages which prints out a menu |
| 2081 | ** of links for the various type=XXX flags. zCurrentViewName must be |
| 2082 | ** the name/value of the 'view' parameter which is in effect at |
| 2083 | ** the time this is called. e.g. if called from the 'byuser' view |
| 2084 | ** then zCurrentViewName must be "byuser". |
| 2085 | */ |
| 2086 | static void stats_report_event_types_menu(char const * zCurrentViewName){ |
| 2087 | char * zTop = mprintf("%s/reports?view=%s", g.zTop, zCurrentViewName); |
| 2088 | cgi_printf("<div>"); |
| 2089 | cgi_printf("<span>Event types:</span> "); |
| 2090 | if('*' == statsReportType){ |
| 2091 | cgi_printf(" <strong>all</strong>", zTop); |
| 2092 | }else{ |
| @@ -2173,11 +2181,11 @@ | |
| 2173 | int nMaxEvents = 1; /* for calculating length of graph |
| 2174 | bars. */ |
| 2175 | int iterations = 0; /* number of weeks/months we iterate |
| 2176 | over */ |
| 2177 | stats_report_init_view(); |
| 2178 | stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear" ); |
| 2179 | blob_appendf(&header, "Timeline Events (%s) by year%s", |
| 2180 | stats_report_label_for_type(), |
| 2181 | (includeMonth ? "/month" : "")); |
| 2182 | blob_appendf(&sql, |
| 2183 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| @@ -2324,11 +2332,11 @@ | |
| 2324 | row colors */ |
| 2325 | Blob sql = empty_blob; /* SQL */ |
| 2326 | int nMaxEvents = 1; /* max number of events for |
| 2327 | all rows. */ |
| 2328 | stats_report_init_view(); |
| 2329 | stats_report_event_types_menu("byuser"); |
| 2330 | blob_append(&sql, |
| 2331 | "SELECT user, " |
| 2332 | "COUNT(*) AS eventCount " |
| 2333 | "FROM v_reports " |
| 2334 | "GROUP BY user ORDER BY eventCount DESC", |
| @@ -2395,21 +2403,28 @@ | |
| 2395 | Blob sql = empty_blob; |
| 2396 | int nMaxEvents = 1; /* max number of events for |
| 2397 | all rows. */ |
| 2398 | int iterations = 0; /* # of active time periods. */ |
| 2399 | stats_report_init_view(); |
| 2400 | stats_report_event_types_menu("byweek"); |
| 2401 | cgi_printf("Select year: "); |
| 2402 | blob_append(&sql, |
| 2403 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2404 | "FROM v_reports WHERE 1 ", -1); |
| 2405 | if(zUserName&&*zUserName){ |
| 2406 | blob_appendf(&sql,"AND user=%Q ", zUserName); |
| 2407 | } |
| 2408 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2409 | db_prepare(&qYears, blob_str(&sql)); |
| 2410 | blob_reset(&sql); |
| 2411 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2412 | const char * zT = db_column_text(&qYears, 0); |
| 2413 | if( i++ ){ |
| 2414 | cgi_printf(" "); |
| 2415 | } |
| 2416 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -2077,16 +2077,24 @@ | |
| 2077 | } |
| 2078 | |
| 2079 | /* |
| 2080 | ** A helper for the /reports family of pages which prints out a menu |
| 2081 | ** of links for the various type=XXX flags. zCurrentViewName must be |
| 2082 | ** the name/value of the 'view' parameter which is in effect at the |
| 2083 | ** time this is called. e.g. if called from the 'byuser' view then |
| 2084 | ** zCurrentViewName must be "byuser". Any URL parameters which need to |
| 2085 | ** be added to the generated URLs should be passed in zParam. The |
| 2086 | ** caller is expected to have already encoded any zParam in the %T or |
| 2087 | ** %t encoding. */ |
| 2088 | static void stats_report_event_types_menu(char const * zCurrentViewName, |
| 2089 | char const * zParam){ |
| 2090 | char * zTop; |
| 2091 | if(zParam && !*zParam){ |
| 2092 | zParam = NULL; |
| 2093 | } |
| 2094 | zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName, |
| 2095 | zParam ? "&" : "", zParam); |
| 2096 | cgi_printf("<div>"); |
| 2097 | cgi_printf("<span>Event types:</span> "); |
| 2098 | if('*' == statsReportType){ |
| 2099 | cgi_printf(" <strong>all</strong>", zTop); |
| 2100 | }else{ |
| @@ -2173,11 +2181,11 @@ | |
| 2181 | int nMaxEvents = 1; /* for calculating length of graph |
| 2182 | bars. */ |
| 2183 | int iterations = 0; /* number of weeks/months we iterate |
| 2184 | over */ |
| 2185 | stats_report_init_view(); |
| 2186 | stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear", NULL ); |
| 2187 | blob_appendf(&header, "Timeline Events (%s) by year%s", |
| 2188 | stats_report_label_for_type(), |
| 2189 | (includeMonth ? "/month" : "")); |
| 2190 | blob_appendf(&sql, |
| 2191 | "SELECT substr(date(mtime),1,%d) AS timeframe, " |
| @@ -2324,11 +2332,11 @@ | |
| 2332 | row colors */ |
| 2333 | Blob sql = empty_blob; /* SQL */ |
| 2334 | int nMaxEvents = 1; /* max number of events for |
| 2335 | all rows. */ |
| 2336 | stats_report_init_view(); |
| 2337 | stats_report_event_types_menu("byuser", NULL); |
| 2338 | blob_append(&sql, |
| 2339 | "SELECT user, " |
| 2340 | "COUNT(*) AS eventCount " |
| 2341 | "FROM v_reports " |
| 2342 | "GROUP BY user ORDER BY eventCount DESC", |
| @@ -2395,21 +2403,28 @@ | |
| 2403 | Blob sql = empty_blob; |
| 2404 | int nMaxEvents = 1; /* max number of events for |
| 2405 | all rows. */ |
| 2406 | int iterations = 0; /* # of active time periods. */ |
| 2407 | stats_report_init_view(); |
| 2408 | if(4==nYear){ |
| 2409 | Blob urlParams = empty_blob; |
| 2410 | blob_appendf(&urlParams, "y=%T", zYear); |
| 2411 | stats_report_event_types_menu("byweek", blob_str(&urlParams)); |
| 2412 | blob_reset(&urlParams); |
| 2413 | }else{ |
| 2414 | stats_report_event_types_menu("byweek", NULL); |
| 2415 | } |
| 2416 | blob_append(&sql, |
| 2417 | "SELECT DISTINCT substr(date(mtime),1,4) AS y " |
| 2418 | "FROM v_reports WHERE 1 ", -1); |
| 2419 | if(zUserName&&*zUserName){ |
| 2420 | blob_appendf(&sql,"AND user=%Q ", zUserName); |
| 2421 | } |
| 2422 | blob_append(&sql,"GROUP BY y ORDER BY y", -1); |
| 2423 | db_prepare(&qYears, blob_str(&sql)); |
| 2424 | blob_reset(&sql); |
| 2425 | cgi_printf("Select year: "); |
| 2426 | while( SQLITE_ROW == db_step(&qYears) ){ |
| 2427 | const char * zT = db_column_text(&qYears, 0); |
| 2428 | if( i++ ){ |
| 2429 | cgi_printf(" "); |
| 2430 | } |
| 2431 |