Fossil SCM

added /json/report/get.

stephan 2011-10-08 14:16 UTC json-multitag-test
Commit e21b391dcd355a91c1c636d90b91eb7a5c78da96
--- ajax/index.html
+++ ajax/index.html
@@ -261,10 +261,13 @@
261261
<input type='button' value='query'
262262
onclick='TheApp.cgi.sendCommand("/json/query?format=o","SELECT * from user")' />
263263
264264
<input type='button' value='report list'
265265
onclick='TheApp.cgi.sendCommand("/json/report/list")' />
266
+<input type='button' value='report get'
267
+ onclick='TheApp.cgi.sendCommand("/json/report/get",2)' />
268
+
266269
<input type='button' value='report run'
267270
onclick='TheApp.cgi.sendCommand("/json/report/run",{"report":2,"format":"o"})' />
268271
269272
<!-- not yet ready...
270273
<input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' />
271274
--- ajax/index.html
+++ ajax/index.html
@@ -261,10 +261,13 @@
261 <input type='button' value='query'
262 onclick='TheApp.cgi.sendCommand("/json/query?format=o","SELECT * from user")' />
263
264 <input type='button' value='report list'
265 onclick='TheApp.cgi.sendCommand("/json/report/list")' />
 
 
 
266 <input type='button' value='report run'
267 onclick='TheApp.cgi.sendCommand("/json/report/run",{"report":2,"format":"o"})' />
268
269 <!-- not yet ready...
270 <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' />
271
--- ajax/index.html
+++ ajax/index.html
@@ -261,10 +261,13 @@
261 <input type='button' value='query'
262 onclick='TheApp.cgi.sendCommand("/json/query?format=o","SELECT * from user")' />
263
264 <input type='button' value='report list'
265 onclick='TheApp.cgi.sendCommand("/json/report/list")' />
266 <input type='button' value='report get'
267 onclick='TheApp.cgi.sendCommand("/json/report/get",2)' />
268
269 <input type='button' value='report run'
270 onclick='TheApp.cgi.sendCommand("/json/report/run",{"report":2,"format":"o"})' />
271
272 <!-- not yet ready...
273 <input type='button' value='artifact/XYZ' onclick='TheApp.cgi.sendCommand("/json/artifact?uuid=json")' />
274
--- src/json_report.c
+++ src/json_report.c
@@ -64,10 +64,13 @@
6464
**
6565
** Returns >0 (the report number) on success .
6666
*/
6767
static int json_report_get_number(int argPos){
6868
int nReport = json_find_option_int("report",NULL,"r",-1);
69
+ if( (nReport<=0) && cson_value_is_integer(g.json.reqPayload.v)){
70
+ nReport = cson_value_get_integer(g.json.reqPayload.v);
71
+ }
6972
if( (nReport <= 0) && (argPos>0) ){
7073
char const * arg = json_command_arg(argPos);
7174
if(arg && fossil_isdigit(*arg)) {
7275
nReport = atoi(arg);
7376
}
@@ -78,11 +81,44 @@
7881
static cson_value * json_report_create(){
7982
return NULL;
8083
}
8184
8285
static cson_value * json_report_get(){
83
- return NULL;
86
+ int nReport;
87
+ Stmt q = empty_Stmt;
88
+ cson_value * pay = NULL;
89
+
90
+ if(!g.perm.TktFmt){
91
+ json_set_err(FSL_JSON_E_DENIED,
92
+ "Requires 't' privileges.");
93
+ return NULL;
94
+ }
95
+ nReport = json_report_get_number(3);
96
+ if(nReport <=0){
97
+ json_set_err(FSL_JSON_E_MISSING_ARGS,
98
+ "Missing or invalid 'number' (-n) parameter.");
99
+ return NULL;
100
+ }
101
+
102
+ db_prepare(&q,"SELECT rn AS rn,"
103
+ " owner AS owner,"
104
+ " title AS title,"
105
+ " strftime('%%s',mtime) as mtime,"
106
+ " cols as columns,"
107
+ " sqlcode as sqlCode"
108
+ " FROM reportfmt"
109
+ " WHERE rn=%d",
110
+ nReport);
111
+ if( SQLITE_ROW != db_step(&q) ){
112
+ db_finalize(&q);
113
+ json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND,
114
+ "Report #%d not found.", nReport);
115
+ return NULL;
116
+ }
117
+ pay = cson_sqlite3_row_to_object(q.pStmt);
118
+ db_finalize(&q);
119
+ return pay;
84120
}
85121
86122
/*
87123
** Impl of /json/report/list.
88124
*/
89125
--- src/json_report.c
+++ src/json_report.c
@@ -64,10 +64,13 @@
64 **
65 ** Returns >0 (the report number) on success .
66 */
67 static int json_report_get_number(int argPos){
68 int nReport = json_find_option_int("report",NULL,"r",-1);
 
 
 
69 if( (nReport <= 0) && (argPos>0) ){
70 char const * arg = json_command_arg(argPos);
71 if(arg && fossil_isdigit(*arg)) {
72 nReport = atoi(arg);
73 }
@@ -78,11 +81,44 @@
78 static cson_value * json_report_create(){
79 return NULL;
80 }
81
82 static cson_value * json_report_get(){
83 return NULL;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84 }
85
86 /*
87 ** Impl of /json/report/list.
88 */
89
--- src/json_report.c
+++ src/json_report.c
@@ -64,10 +64,13 @@
64 **
65 ** Returns >0 (the report number) on success .
66 */
67 static int json_report_get_number(int argPos){
68 int nReport = json_find_option_int("report",NULL,"r",-1);
69 if( (nReport<=0) && cson_value_is_integer(g.json.reqPayload.v)){
70 nReport = cson_value_get_integer(g.json.reqPayload.v);
71 }
72 if( (nReport <= 0) && (argPos>0) ){
73 char const * arg = json_command_arg(argPos);
74 if(arg && fossil_isdigit(*arg)) {
75 nReport = atoi(arg);
76 }
@@ -78,11 +81,44 @@
81 static cson_value * json_report_create(){
82 return NULL;
83 }
84
85 static cson_value * json_report_get(){
86 int nReport;
87 Stmt q = empty_Stmt;
88 cson_value * pay = NULL;
89
90 if(!g.perm.TktFmt){
91 json_set_err(FSL_JSON_E_DENIED,
92 "Requires 't' privileges.");
93 return NULL;
94 }
95 nReport = json_report_get_number(3);
96 if(nReport <=0){
97 json_set_err(FSL_JSON_E_MISSING_ARGS,
98 "Missing or invalid 'number' (-n) parameter.");
99 return NULL;
100 }
101
102 db_prepare(&q,"SELECT rn AS rn,"
103 " owner AS owner,"
104 " title AS title,"
105 " strftime('%%s',mtime) as mtime,"
106 " cols as columns,"
107 " sqlcode as sqlCode"
108 " FROM reportfmt"
109 " WHERE rn=%d",
110 nReport);
111 if( SQLITE_ROW != db_step(&q) ){
112 db_finalize(&q);
113 json_set_err(FSL_JSON_E_RESOURCE_NOT_FOUND,
114 "Report #%d not found.", nReport);
115 return NULL;
116 }
117 pay = cson_sqlite3_row_to_object(q.pStmt);
118 db_finalize(&q);
119 return pay;
120 }
121
122 /*
123 ** Impl of /json/report/list.
124 */
125

Keyboard Shortcuts

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