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.

drh 2018-02-05 20:18 trunk
Commit f390552d0e5c0174560772f81096910178185165b15fea2ad4ed101049d0c8a0
1 file changed +11 -3
+11 -3
--- src/statrep.c
+++ src/statrep.c
@@ -58,10 +58,11 @@
5858
*/
5959
static int stats_report_init_view(){
6060
const char *zType = PD("type","*"); /* analog to /timeline?y=... */
6161
const char *zRealType = NULL; /* normalized form of zType */
6262
int rc = 0; /* result code */
63
+ char *zTimeSpan; /* Time span */
6364
assert( !statsReportType && "Must not be called more than once." );
6465
switch( (zType && *zType) ? *zType : 0 ){
6566
case 'c':
6667
case 'C':
6768
zRealType = "ci";
@@ -90,19 +91,26 @@
9091
default:
9192
rc = '*';
9293
break;
9394
}
9495
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
+ }
95103
if(zRealType){
96104
statsReportTimelineYFlag = zRealType;
97105
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*/);
100108
}else{
101109
statsReportTimelineYFlag = "a";
102110
db_multi_exec("CREATE TEMP VIEW v_reports AS "
103
- "SELECT * FROM event");
111
+ "SELECT * FROM event WHERE %s", zTimeSpan/*safe-for-%s*/);
104112
}
105113
return statsReportType = rc;
106114
}
107115
108116
/*
109117
--- 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

Keyboard Shortcuts

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