Fossil SCM

Added ticketUuid to /json/timeline/ticket output. Removed some superfluous Blob uses (where db_prepare() works just as well).

stephan 2011-09-27 04:08 UTC json
Commit f94ad194723086c5add6d01f4a2406ff0899ad5f
1 file changed +64 -64
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -275,42 +275,37 @@
275275
#define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
276276
g.json.resultCode = (cson_rc.AllocError==check) \
277277
? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN; \
278278
goto error;\
279279
}
280
- db_multi_exec(blob_buffer(&sql));
281
-
282280
#if 0
283281
/* only for testing! */
284282
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
285283
SET("timelineSql");
286284
#endif
287
-
288
- blob_reset(&sql);
289
- blob_append(&sql, "SELECT "
290
- " rid AS rid,"
291
- " uuid AS uuid,"
292
- " mtime AS timestamp,"
293
-#if 0
294
- " timestampString AS timestampString,"
295
-#endif
296
- " comment AS comment, "
297
- " user AS user,"
298
- " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
299
- " bgColor AS bgColor," /* why always null? */
300
- " eventType AS eventType,"
301
- " tags AS tags" /*FIXME: split this into
302
- a JSON array*/
303
-#if 0
304
- /*tagId is always null?*/
305
- " tagId AS tagId"
306
-#endif
307
- " FROM json_timeline"
308
- " ORDER BY sortId",
309
- -1);
310
- db_prepare(&q,blob_buffer(&sql));
311
- blob_reset(&sql);
285
+ db_multi_exec(blob_buffer(&sql));
286
+ blob_reset(&sql);
287
+ db_prepare(&q, "SELECT "
288
+ " rid AS rid,"
289
+ " uuid AS uuid,"
290
+ " mtime AS timestamp,"
291
+#if 0
292
+ " timestampString AS timestampString,"
293
+#endif
294
+ " comment AS comment, "
295
+ " user AS user,"
296
+ " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
297
+ " bgColor AS bgColor," /* why always null? */
298
+ " eventType AS eventType,"
299
+ " tags AS tags" /*FIXME: split this into
300
+ a JSON array*/
301
+#if 0
302
+ /*tagId is always null?*/
303
+ " tagId AS tagId"
304
+#endif
305
+ " FROM json_timeline"
306
+ " ORDER BY sortId");
312307
listV = cson_value_new_array();
313308
list = cson_value_get_array(listV);
314309
tmp = listV;
315310
SET("timeline");
316311
while( (SQLITE_ROW == db_step(&q) )){
@@ -394,39 +389,35 @@
394389
#define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
395390
g.json.resultCode = (cson_rc.AllocError==check) \
396391
? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN; \
397392
goto error;\
398393
}
399
- db_multi_exec(blob_buffer(&sql));
400
-
401394
#if 0
402395
/* only for testing! */
403396
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
404397
SET("timelineSql");
405398
#endif
406
-
407
- blob_reset(&sql);
408
- blob_append(&sql, "SELECT rid AS rid,"
409
- " uuid AS uuid,"
410
- " mtime AS timestamp,"
411
-#if 0
412
- " timestampString AS timestampString,"
413
-#endif
414
- " comment AS comment, "
415
- " user AS user,"
416
- " eventType AS eventType"
417
-#if 0
418
- /* can wiki pages have tags? */
419
- " tags AS tags," /*FIXME: split this into
420
- a JSON array*/
421
- " tagId AS tagId,"
422
-#endif
423
- " FROM json_timeline"
424
- " ORDER BY sortId",
425
- -1);
426
- db_prepare(&q, blob_buffer(&sql));
427
- blob_reset(&sql);
399
+ db_multi_exec(blob_buffer(&sql));
400
+ blob_reset(&sql);
401
+ db_prepare(&q, "SELECT rid AS rid,"
402
+ " uuid AS uuid,"
403
+ " mtime AS timestamp,"
404
+#if 0
405
+ " timestampString AS timestampString,"
406
+#endif
407
+ " comment AS comment, "
408
+ " user AS user,"
409
+ " eventType AS eventType"
410
+#if 0
411
+ /* can wiki pages have tags? */
412
+ " tags AS tags," /*FIXME: split this into
413
+ a JSON array*/
414
+ " tagId AS tagId,"
415
+#endif
416
+ " FROM json_timeline"
417
+ " ORDER BY sortId",
418
+ -1);
428419
listV = cson_value_new_array();
429420
list = cson_value_get_array(listV);
430421
tmp = listV;
431422
SET("timeline");
432423
while( (SQLITE_ROW == db_step(&q) )){
@@ -492,38 +483,47 @@
492483
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
493484
SET("timelineSql");
494485
#endif
495486
496487
blob_reset(&sql);
497
- blob_append(&sql, "SELECT rid AS rid,"
498
- " uuid AS uuid,"
499
- " mtime AS timestamp,"
488
+ db_prepare(&q, "SELECT rid AS rid,"
489
+ " uuid AS uuid,"
490
+ " mtime AS timestamp,"
500491
#if 0
501
- " timestampString AS timestampString,"
492
+ " timestampString AS timestampString,"
502493
#endif
503
- " user AS user,"
504
- " eventType AS eventType,"
505
- " comment AS comment,"
506
- " brief AS briefComment"
507
- " FROM json_timeline"
508
- " ORDER BY sortId",
509
- -1);
510
- db_prepare(&q,blob_buffer(&sql));
511
- blob_reset(&sql);
494
+ " user AS user,"
495
+ " eventType AS eventType,"
496
+ " comment AS comment,"
497
+ " brief AS briefComment"
498
+ " FROM json_timeline"
499
+ " ORDER BY sortId",
500
+ -1);
512501
listV = cson_value_new_array();
513502
list = cson_value_get_array(listV);
514503
tmp = listV;
515504
SET("timeline");
516505
while( (SQLITE_ROW == db_step(&q) )){
517506
/* convert each row into a JSON object...*/
518507
int rc;
508
+ int const rid = db_column_int(&q,0);
509
+ Manifest * pMan = NULL;
519510
cson_value * rowV = cson_sqlite3_row_to_object(q.pStmt);
520511
cson_object * row = cson_value_get_object(rowV);
521512
if(!row){
522513
json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED,
523514
"Could not convert at least one timeline result row to JSON." );
524515
continue;
516
+ }
517
+ pMan = manifest_get(rid, CFTYPE_TICKET);
518
+ assert( pMan && "Manifest is NULL!?!" );
519
+ if( pMan ){
520
+ /* FIXME: certainly there's a more efficient way for use to get
521
+ the ticket UUIDs?
522
+ */
523
+ cson_object_set(row,"ticketUuid",json_new_string(pMan->zTicketUuid));
524
+ manifest_destroy(pMan);
525525
}
526526
rc = cson_array_append( list, rowV );
527527
if( 0 != rc ){
528528
cson_value_free(rowV);
529529
g.json.resultCode = (cson_rc.AllocError==rc)
530530
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -275,42 +275,37 @@
275 #define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
276 g.json.resultCode = (cson_rc.AllocError==check) \
277 ? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN; \
278 goto error;\
279 }
280 db_multi_exec(blob_buffer(&sql));
281
282 #if 0
283 /* only for testing! */
284 tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
285 SET("timelineSql");
286 #endif
287
288 blob_reset(&sql);
289 blob_append(&sql, "SELECT "
290 " rid AS rid,"
291 " uuid AS uuid,"
292 " mtime AS timestamp,"
293 #if 0
294 " timestampString AS timestampString,"
295 #endif
296 " comment AS comment, "
297 " user AS user,"
298 " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
299 " bgColor AS bgColor," /* why always null? */
300 " eventType AS eventType,"
301 " tags AS tags" /*FIXME: split this into
302 a JSON array*/
303 #if 0
304 /*tagId is always null?*/
305 " tagId AS tagId"
306 #endif
307 " FROM json_timeline"
308 " ORDER BY sortId",
309 -1);
310 db_prepare(&q,blob_buffer(&sql));
311 blob_reset(&sql);
312 listV = cson_value_new_array();
313 list = cson_value_get_array(listV);
314 tmp = listV;
315 SET("timeline");
316 while( (SQLITE_ROW == db_step(&q) )){
@@ -394,39 +389,35 @@
394 #define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
395 g.json.resultCode = (cson_rc.AllocError==check) \
396 ? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN; \
397 goto error;\
398 }
399 db_multi_exec(blob_buffer(&sql));
400
401 #if 0
402 /* only for testing! */
403 tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
404 SET("timelineSql");
405 #endif
406
407 blob_reset(&sql);
408 blob_append(&sql, "SELECT rid AS rid,"
409 " uuid AS uuid,"
410 " mtime AS timestamp,"
411 #if 0
412 " timestampString AS timestampString,"
413 #endif
414 " comment AS comment, "
415 " user AS user,"
416 " eventType AS eventType"
417 #if 0
418 /* can wiki pages have tags? */
419 " tags AS tags," /*FIXME: split this into
420 a JSON array*/
421 " tagId AS tagId,"
422 #endif
423 " FROM json_timeline"
424 " ORDER BY sortId",
425 -1);
426 db_prepare(&q, blob_buffer(&sql));
427 blob_reset(&sql);
428 listV = cson_value_new_array();
429 list = cson_value_get_array(listV);
430 tmp = listV;
431 SET("timeline");
432 while( (SQLITE_ROW == db_step(&q) )){
@@ -492,38 +483,47 @@
492 tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
493 SET("timelineSql");
494 #endif
495
496 blob_reset(&sql);
497 blob_append(&sql, "SELECT rid AS rid,"
498 " uuid AS uuid,"
499 " mtime AS timestamp,"
500 #if 0
501 " timestampString AS timestampString,"
502 #endif
503 " user AS user,"
504 " eventType AS eventType,"
505 " comment AS comment,"
506 " brief AS briefComment"
507 " FROM json_timeline"
508 " ORDER BY sortId",
509 -1);
510 db_prepare(&q,blob_buffer(&sql));
511 blob_reset(&sql);
512 listV = cson_value_new_array();
513 list = cson_value_get_array(listV);
514 tmp = listV;
515 SET("timeline");
516 while( (SQLITE_ROW == db_step(&q) )){
517 /* convert each row into a JSON object...*/
518 int rc;
 
 
519 cson_value * rowV = cson_sqlite3_row_to_object(q.pStmt);
520 cson_object * row = cson_value_get_object(rowV);
521 if(!row){
522 json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED,
523 "Could not convert at least one timeline result row to JSON." );
524 continue;
 
 
 
 
 
 
 
 
 
525 }
526 rc = cson_array_append( list, rowV );
527 if( 0 != rc ){
528 cson_value_free(rowV);
529 g.json.resultCode = (cson_rc.AllocError==rc)
530
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -275,42 +275,37 @@
275 #define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
276 g.json.resultCode = (cson_rc.AllocError==check) \
277 ? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN; \
278 goto error;\
279 }
 
 
280 #if 0
281 /* only for testing! */
282 tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
283 SET("timelineSql");
284 #endif
285 db_multi_exec(blob_buffer(&sql));
286 blob_reset(&sql);
287 db_prepare(&q, "SELECT "
288 " rid AS rid,"
289 " uuid AS uuid,"
290 " mtime AS timestamp,"
291 #if 0
292 " timestampString AS timestampString,"
293 #endif
294 " comment AS comment, "
295 " user AS user,"
296 " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */
297 " bgColor AS bgColor," /* why always null? */
298 " eventType AS eventType,"
299 " tags AS tags" /*FIXME: split this into
300 a JSON array*/
301 #if 0
302 /*tagId is always null?*/
303 " tagId AS tagId"
304 #endif
305 " FROM json_timeline"
306 " ORDER BY sortId");
 
 
 
307 listV = cson_value_new_array();
308 list = cson_value_get_array(listV);
309 tmp = listV;
310 SET("timeline");
311 while( (SQLITE_ROW == db_step(&q) )){
@@ -394,39 +389,35 @@
389 #define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
390 g.json.resultCode = (cson_rc.AllocError==check) \
391 ? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN; \
392 goto error;\
393 }
 
 
394 #if 0
395 /* only for testing! */
396 tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
397 SET("timelineSql");
398 #endif
399 db_multi_exec(blob_buffer(&sql));
400 blob_reset(&sql);
401 db_prepare(&q, "SELECT rid AS rid,"
402 " uuid AS uuid,"
403 " mtime AS timestamp,"
404 #if 0
405 " timestampString AS timestampString,"
406 #endif
407 " comment AS comment, "
408 " user AS user,"
409 " eventType AS eventType"
410 #if 0
411 /* can wiki pages have tags? */
412 " tags AS tags," /*FIXME: split this into
413 a JSON array*/
414 " tagId AS tagId,"
415 #endif
416 " FROM json_timeline"
417 " ORDER BY sortId",
418 -1);
 
 
419 listV = cson_value_new_array();
420 list = cson_value_get_array(listV);
421 tmp = listV;
422 SET("timeline");
423 while( (SQLITE_ROW == db_step(&q) )){
@@ -492,38 +483,47 @@
483 tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
484 SET("timelineSql");
485 #endif
486
487 blob_reset(&sql);
488 db_prepare(&q, "SELECT rid AS rid,"
489 " uuid AS uuid,"
490 " mtime AS timestamp,"
491 #if 0
492 " timestampString AS timestampString,"
493 #endif
494 " user AS user,"
495 " eventType AS eventType,"
496 " comment AS comment,"
497 " brief AS briefComment"
498 " FROM json_timeline"
499 " ORDER BY sortId",
500 -1);
 
 
501 listV = cson_value_new_array();
502 list = cson_value_get_array(listV);
503 tmp = listV;
504 SET("timeline");
505 while( (SQLITE_ROW == db_step(&q) )){
506 /* convert each row into a JSON object...*/
507 int rc;
508 int const rid = db_column_int(&q,0);
509 Manifest * pMan = NULL;
510 cson_value * rowV = cson_sqlite3_row_to_object(q.pStmt);
511 cson_object * row = cson_value_get_object(rowV);
512 if(!row){
513 json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED,
514 "Could not convert at least one timeline result row to JSON." );
515 continue;
516 }
517 pMan = manifest_get(rid, CFTYPE_TICKET);
518 assert( pMan && "Manifest is NULL!?!" );
519 if( pMan ){
520 /* FIXME: certainly there's a more efficient way for use to get
521 the ticket UUIDs?
522 */
523 cson_object_set(row,"ticketUuid",json_new_string(pMan->zTicketUuid));
524 manifest_destroy(pMan);
525 }
526 rc = cson_array_append( list, rowV );
527 if( 0 != rc ){
528 cson_value_free(rowV);
529 g.json.resultCode = (cson_rc.AllocError==rc)
530

Keyboard Shortcuts

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