Fossil SCM
Add /json/timeline/event for access to minimal information about events.
Commit
c760791644ad94f52ee7396accbb8aaf685311c687e0be6f92a210abd1a5fb8e
Parent
862d630ffb8821c…
1 file changed
+62
+62
| --- src/json_timeline.c | ||
| +++ src/json_timeline.c | ||
| @@ -35,10 +35,11 @@ | ||
| 35 | 35 | that we end up with HTTP clients using 3 different names |
| 36 | 36 | for the same requests. |
| 37 | 37 | */ |
| 38 | 38 | {"branch", json_timeline_branch, 0}, |
| 39 | 39 | {"checkin", json_timeline_ci, 0}, |
| 40 | +{"event", json_timeline_event, 0}, | |
| 40 | 41 | {"ticket", json_timeline_ticket, 0}, |
| 41 | 42 | {"wiki", json_timeline_wiki, 0}, |
| 42 | 43 | /* Last entry MUST have a NULL name. */ |
| 43 | 44 | {NULL,NULL,0} |
| 44 | 45 | }; |
| @@ -519,10 +520,71 @@ | ||
| 519 | 520 | payV = NULL; |
| 520 | 521 | ok: |
| 521 | 522 | db_finalize(&q); |
| 522 | 523 | return payV; |
| 523 | 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 | + " uuid AS uuid," | |
| 558 | + " mtime AS timestamp," | |
| 559 | +#if 0 | |
| 560 | + " timestampString AS timestampString," | |
| 561 | +#endif | |
| 562 | + " comment AS comment, " | |
| 563 | + " user AS user," | |
| 564 | + " eventType AS eventType" | |
| 565 | +#if 0 | |
| 566 | + /* TODO implement tags for events */ | |
| 567 | + " tags AS tags," /*FIXME: split this into | |
| 568 | + a JSON array*/ | |
| 569 | + " tagId AS tagId," | |
| 570 | +#endif | |
| 571 | + " FROM json_timeline" | |
| 572 | + " ORDER BY rowid"); | |
| 573 | + list = cson_new_array(); | |
| 574 | + json_stmt_to_array_of_obj(&q, list); | |
| 575 | + cson_object_set(pay, "timeline", cson_array_value(list)); | |
| 576 | + goto ok; | |
| 577 | + error: | |
| 578 | + assert( 0 != g.json.resultCode ); | |
| 579 | + cson_value_free(payV); | |
| 580 | + payV = NULL; | |
| 581 | + ok: | |
| 582 | + db_finalize(&q); | |
| 583 | + blob_reset(&sql); | |
| 584 | + return payV; | |
| 585 | +} | |
| 524 | 586 | |
| 525 | 587 | /* |
| 526 | 588 | ** Implementation of /json/timeline/wiki. |
| 527 | 589 | ** |
| 528 | 590 | */ |
| 529 | 591 |
| --- 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,71 @@ | |
| 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,71 @@ | |
| 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 | " uuid AS uuid," |
| 558 | " mtime AS timestamp," |
| 559 | #if 0 |
| 560 | " timestampString AS timestampString," |
| 561 | #endif |
| 562 | " comment AS comment, " |
| 563 | " user AS user," |
| 564 | " eventType AS eventType" |
| 565 | #if 0 |
| 566 | /* TODO implement tags for events */ |
| 567 | " tags AS tags," /*FIXME: split this into |
| 568 | a JSON array*/ |
| 569 | " tagId AS tagId," |
| 570 | #endif |
| 571 | " FROM json_timeline" |
| 572 | " ORDER BY rowid"); |
| 573 | list = cson_new_array(); |
| 574 | json_stmt_to_array_of_obj(&q, list); |
| 575 | cson_object_set(pay, "timeline", cson_array_value(list)); |
| 576 | goto ok; |
| 577 | error: |
| 578 | assert( 0 != g.json.resultCode ); |
| 579 | cson_value_free(payV); |
| 580 | payV = NULL; |
| 581 | ok: |
| 582 | db_finalize(&q); |
| 583 | blob_reset(&sql); |
| 584 | return payV; |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | ** Implementation of /json/timeline/wiki. |
| 589 | ** |
| 590 | */ |
| 591 |