Fossil SCM

/reports byweek fix: the currently selected year is now propagated across the event-type links.

stephan 2014-01-25 16:23 trunk
Commit cba6bbf89c45987a03cf758e971f43d5787500ba
1 file changed +25 -10
+25 -10
--- src/timeline.c
+++ src/timeline.c
@@ -2077,16 +2077,24 @@
20772077
}
20782078
20792079
/*
20802080
** A helper for the /reports family of pages which prints out a menu
20812081
** 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);
20882096
cgi_printf("<div>");
20892097
cgi_printf("<span>Event types:</span> ");
20902098
if('*' == statsReportType){
20912099
cgi_printf(" <strong>all</strong>", zTop);
20922100
}else{
@@ -2173,11 +2181,11 @@
21732181
int nMaxEvents = 1; /* for calculating length of graph
21742182
bars. */
21752183
int iterations = 0; /* number of weeks/months we iterate
21762184
over */
21772185
stats_report_init_view();
2178
- stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear" );
2186
+ stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear", NULL );
21792187
blob_appendf(&header, "Timeline Events (%s) by year%s",
21802188
stats_report_label_for_type(),
21812189
(includeMonth ? "/month" : ""));
21822190
blob_appendf(&sql,
21832191
"SELECT substr(date(mtime),1,%d) AS timeframe, "
@@ -2324,11 +2332,11 @@
23242332
row colors */
23252333
Blob sql = empty_blob; /* SQL */
23262334
int nMaxEvents = 1; /* max number of events for
23272335
all rows. */
23282336
stats_report_init_view();
2329
- stats_report_event_types_menu("byuser");
2337
+ stats_report_event_types_menu("byuser", NULL);
23302338
blob_append(&sql,
23312339
"SELECT user, "
23322340
"COUNT(*) AS eventCount "
23332341
"FROM v_reports "
23342342
"GROUP BY user ORDER BY eventCount DESC",
@@ -2395,21 +2403,28 @@
23952403
Blob sql = empty_blob;
23962404
int nMaxEvents = 1; /* max number of events for
23972405
all rows. */
23982406
int iterations = 0; /* # of active time periods. */
23992407
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
+ }
24022416
blob_append(&sql,
24032417
"SELECT DISTINCT substr(date(mtime),1,4) AS y "
24042418
"FROM v_reports WHERE 1 ", -1);
24052419
if(zUserName&&*zUserName){
24062420
blob_appendf(&sql,"AND user=%Q ", zUserName);
24072421
}
24082422
blob_append(&sql,"GROUP BY y ORDER BY y", -1);
24092423
db_prepare(&qYears, blob_str(&sql));
24102424
blob_reset(&sql);
2425
+ cgi_printf("Select year: ");
24112426
while( SQLITE_ROW == db_step(&qYears) ){
24122427
const char * zT = db_column_text(&qYears, 0);
24132428
if( i++ ){
24142429
cgi_printf(" ");
24152430
}
24162431
--- 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

Keyboard Shortcuts

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