Fossil SCM

Merged in ben-json-timeline (adds /json/timeline/event).

stephan 2018-08-03 21:06 trunk merge
Commit 74c908e709776cdb3ae75703b4c395ce558f6e4fe39d4db32cd1e7039dc436bb
1 file changed +57
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -35,10 +35,11 @@
3535
that we end up with HTTP clients using 3 different names
3636
for the same requests.
3737
*/
3838
{"branch", json_timeline_branch, 0},
3939
{"checkin", json_timeline_ci, 0},
40
+{"event", json_timeline_event, 0},
4041
{"ticket", json_timeline_ticket, 0},
4142
{"wiki", json_timeline_wiki, 0},
4243
/* Last entry MUST have a NULL name. */
4344
{NULL,NULL,0}
4445
};
@@ -519,10 +520,66 @@
519520
payV = NULL;
520521
ok:
521522
db_finalize(&q);
522523
return payV;
523524
}
525
+
526
+/*
527
+** Implementation of /json/timeline/event.
528
+**
529
+*/
530
+cson_value * json_timeline_event(){
531
+ /* This code is 95% the same as json_timeline_ci(), by the way. */
532
+ cson_value * payV = NULL;
533
+ cson_object * pay = NULL;
534
+ cson_array * list = NULL;
535
+ int check = 0;
536
+ Stmt q = empty_Stmt;
537
+ Blob sql = empty_blob;
538
+ if( !g.perm.RdWiki ){
539
+ json_set_err( FSL_JSON_E_DENIED, "Event timeline requires 'j' access.");
540
+ return NULL;
541
+ }
542
+ payV = cson_value_new_object();
543
+ pay = cson_value_get_object(payV);
544
+ check = json_timeline_setup_sql( "e", &sql, pay );
545
+ if(check){
546
+ json_set_err(check, "Query initialization failed.");
547
+ goto error;
548
+ }
549
+
550
+#if 0
551
+ /* only for testing! */
552
+ cson_object_set(pay, "timelineSql", cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql))));
553
+#endif
554
+ db_multi_exec("%s", blob_buffer(&sql) /*safe-for-%s*/);
555
+ blob_reset(&sql);
556
+ db_prepare(&q, "SELECT"
557
+ /* For events, the name is generally more useful than
558
+ the uuid, but the uuid is unambiguous and can be used
559
+ with commands like 'artifact'. */
560
+ " substr((SELECT tagname FROM tag AS tn WHERE tn.tagid=json_timeline.tagId AND tagname LIKE 'event-%%'),7) AS name,"
561
+ " uuid as uuid,"
562
+ " mtime AS timestamp,"
563
+ " comment AS comment, "
564
+ " user AS user,"
565
+ " eventType AS eventType"
566
+ " FROM json_timeline"
567
+ " ORDER BY rowid");
568
+ list = cson_new_array();
569
+ json_stmt_to_array_of_obj(&q, list);
570
+ cson_object_set(pay, "timeline", cson_array_value(list));
571
+ goto ok;
572
+ error:
573
+ assert( 0 != g.json.resultCode );
574
+ cson_value_free(payV);
575
+ payV = NULL;
576
+ ok:
577
+ db_finalize(&q);
578
+ blob_reset(&sql);
579
+ return payV;
580
+}
524581
525582
/*
526583
** Implementation of /json/timeline/wiki.
527584
**
528585
*/
529586
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -35,10 +35,11 @@
35 that we end up with HTTP clients using 3 different names
36 for the same requests.
37 */
38 {"branch", json_timeline_branch, 0},
39 {"checkin", json_timeline_ci, 0},
 
40 {"ticket", json_timeline_ticket, 0},
41 {"wiki", json_timeline_wiki, 0},
42 /* Last entry MUST have a NULL name. */
43 {NULL,NULL,0}
44 };
@@ -519,10 +520,66 @@
519 payV = NULL;
520 ok:
521 db_finalize(&q);
522 return payV;
523 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
524
525 /*
526 ** Implementation of /json/timeline/wiki.
527 **
528 */
529
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -35,10 +35,11 @@
35 that we end up with HTTP clients using 3 different names
36 for the same requests.
37 */
38 {"branch", json_timeline_branch, 0},
39 {"checkin", json_timeline_ci, 0},
40 {"event", json_timeline_event, 0},
41 {"ticket", json_timeline_ticket, 0},
42 {"wiki", json_timeline_wiki, 0},
43 /* Last entry MUST have a NULL name. */
44 {NULL,NULL,0}
45 };
@@ -519,10 +520,66 @@
520 payV = NULL;
521 ok:
522 db_finalize(&q);
523 return payV;
524 }
525
526 /*
527 ** Implementation of /json/timeline/event.
528 **
529 */
530 cson_value * json_timeline_event(){
531 /* This code is 95% the same as json_timeline_ci(), by the way. */
532 cson_value * payV = NULL;
533 cson_object * pay = NULL;
534 cson_array * list = NULL;
535 int check = 0;
536 Stmt q = empty_Stmt;
537 Blob sql = empty_blob;
538 if( !g.perm.RdWiki ){
539 json_set_err( FSL_JSON_E_DENIED, "Event timeline requires 'j' access.");
540 return NULL;
541 }
542 payV = cson_value_new_object();
543 pay = cson_value_get_object(payV);
544 check = json_timeline_setup_sql( "e", &sql, pay );
545 if(check){
546 json_set_err(check, "Query initialization failed.");
547 goto error;
548 }
549
550 #if 0
551 /* only for testing! */
552 cson_object_set(pay, "timelineSql", cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql))));
553 #endif
554 db_multi_exec("%s", blob_buffer(&sql) /*safe-for-%s*/);
555 blob_reset(&sql);
556 db_prepare(&q, "SELECT"
557 /* For events, the name is generally more useful than
558 the uuid, but the uuid is unambiguous and can be used
559 with commands like 'artifact'. */
560 " substr((SELECT tagname FROM tag AS tn WHERE tn.tagid=json_timeline.tagId AND tagname LIKE 'event-%%'),7) AS name,"
561 " uuid as uuid,"
562 " mtime AS timestamp,"
563 " comment AS comment, "
564 " user AS user,"
565 " eventType AS eventType"
566 " FROM json_timeline"
567 " ORDER BY rowid");
568 list = cson_new_array();
569 json_stmt_to_array_of_obj(&q, list);
570 cson_object_set(pay, "timeline", cson_array_value(list));
571 goto ok;
572 error:
573 assert( 0 != g.json.resultCode );
574 cson_value_free(payV);
575 payV = NULL;
576 ok:
577 db_finalize(&q);
578 blob_reset(&sql);
579 return payV;
580 }
581
582 /*
583 ** Implementation of /json/timeline/wiki.
584 **
585 */
586

Keyboard Shortcuts

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