Fossil SCM
Add (undocumented) from= and to= query parameters on the /reports webpage. If both parameters are a date/time string, then report only covers the span of dates specified.
Commit
f390552d0e5c0174560772f81096910178185165b15fea2ad4ed101049d0c8a0
Parent
57f178eecc90678…
1 file changed
+11
-3
+11
-3
| --- src/statrep.c | ||
| +++ src/statrep.c | ||
| @@ -58,10 +58,11 @@ | ||
| 58 | 58 | */ |
| 59 | 59 | static int stats_report_init_view(){ |
| 60 | 60 | const char *zType = PD("type","*"); /* analog to /timeline?y=... */ |
| 61 | 61 | const char *zRealType = NULL; /* normalized form of zType */ |
| 62 | 62 | int rc = 0; /* result code */ |
| 63 | + char *zTimeSpan; /* Time span */ | |
| 63 | 64 | assert( !statsReportType && "Must not be called more than once." ); |
| 64 | 65 | switch( (zType && *zType) ? *zType : 0 ){ |
| 65 | 66 | case 'c': |
| 66 | 67 | case 'C': |
| 67 | 68 | zRealType = "ci"; |
| @@ -90,19 +91,26 @@ | ||
| 90 | 91 | default: |
| 91 | 92 | rc = '*'; |
| 92 | 93 | break; |
| 93 | 94 | } |
| 94 | 95 | assert(0 != rc); |
| 96 | + if( P("from")!=0 && P("to")!=0 ){ | |
| 97 | + zTimeSpan = mprintf( | |
| 98 | + " (event.mtime BETWEEN julianday(%Q) AND julianday(%Q))", | |
| 99 | + P("from"), P("to")); | |
| 100 | + }else{ | |
| 101 | + zTimeSpan = " 1"; | |
| 102 | + } | |
| 95 | 103 | if(zRealType){ |
| 96 | 104 | statsReportTimelineYFlag = zRealType; |
| 97 | 105 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 98 | - "SELECT * FROM event WHERE type GLOB %Q", | |
| 99 | - zRealType); | |
| 106 | + "SELECT * FROM event WHERE (type GLOB %Q) AND %s", | |
| 107 | + zRealType, zTimeSpan/*safe-for-%s*/); | |
| 100 | 108 | }else{ |
| 101 | 109 | statsReportTimelineYFlag = "a"; |
| 102 | 110 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 103 | - "SELECT * FROM event"); | |
| 111 | + "SELECT * FROM event WHERE %s", zTimeSpan/*safe-for-%s*/); | |
| 104 | 112 | } |
| 105 | 113 | return statsReportType = rc; |
| 106 | 114 | } |
| 107 | 115 | |
| 108 | 116 | /* |
| 109 | 117 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -58,10 +58,11 @@ | |
| 58 | */ |
| 59 | static int stats_report_init_view(){ |
| 60 | const char *zType = PD("type","*"); /* analog to /timeline?y=... */ |
| 61 | const char *zRealType = NULL; /* normalized form of zType */ |
| 62 | int rc = 0; /* result code */ |
| 63 | assert( !statsReportType && "Must not be called more than once." ); |
| 64 | switch( (zType && *zType) ? *zType : 0 ){ |
| 65 | case 'c': |
| 66 | case 'C': |
| 67 | zRealType = "ci"; |
| @@ -90,19 +91,26 @@ | |
| 90 | default: |
| 91 | rc = '*'; |
| 92 | break; |
| 93 | } |
| 94 | assert(0 != rc); |
| 95 | if(zRealType){ |
| 96 | statsReportTimelineYFlag = zRealType; |
| 97 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 98 | "SELECT * FROM event WHERE type GLOB %Q", |
| 99 | zRealType); |
| 100 | }else{ |
| 101 | statsReportTimelineYFlag = "a"; |
| 102 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 103 | "SELECT * FROM event"); |
| 104 | } |
| 105 | return statsReportType = rc; |
| 106 | } |
| 107 | |
| 108 | /* |
| 109 |
| --- src/statrep.c | |
| +++ src/statrep.c | |
| @@ -58,10 +58,11 @@ | |
| 58 | */ |
| 59 | static int stats_report_init_view(){ |
| 60 | const char *zType = PD("type","*"); /* analog to /timeline?y=... */ |
| 61 | const char *zRealType = NULL; /* normalized form of zType */ |
| 62 | int rc = 0; /* result code */ |
| 63 | char *zTimeSpan; /* Time span */ |
| 64 | assert( !statsReportType && "Must not be called more than once." ); |
| 65 | switch( (zType && *zType) ? *zType : 0 ){ |
| 66 | case 'c': |
| 67 | case 'C': |
| 68 | zRealType = "ci"; |
| @@ -90,19 +91,26 @@ | |
| 91 | default: |
| 92 | rc = '*'; |
| 93 | break; |
| 94 | } |
| 95 | assert(0 != rc); |
| 96 | if( P("from")!=0 && P("to")!=0 ){ |
| 97 | zTimeSpan = mprintf( |
| 98 | " (event.mtime BETWEEN julianday(%Q) AND julianday(%Q))", |
| 99 | P("from"), P("to")); |
| 100 | }else{ |
| 101 | zTimeSpan = " 1"; |
| 102 | } |
| 103 | if(zRealType){ |
| 104 | statsReportTimelineYFlag = zRealType; |
| 105 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 106 | "SELECT * FROM event WHERE (type GLOB %Q) AND %s", |
| 107 | zRealType, zTimeSpan/*safe-for-%s*/); |
| 108 | }else{ |
| 109 | statsReportTimelineYFlag = "a"; |
| 110 | db_multi_exec("CREATE TEMP VIEW v_reports AS " |
| 111 | "SELECT * FROM event WHERE %s", zTimeSpan/*safe-for-%s*/); |
| 112 | } |
| 113 | return statsReportType = rc; |
| 114 | } |
| 115 | |
| 116 | /* |
| 117 |