Fossil SCM

Changes /json/timeline/branch's payload structure to match that used by the other /json/timeline/xyz APIs. Removed rid property from timeline output.

stephan 2012-03-21 21:06 trunk
Commit bdc29eb897210da6ccb535046e525e44c8a3b10c
1 file changed +15 -1
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -389,23 +389,37 @@
389389
if(pay){
390390
/* get the array-form tags of each record. */
391391
cson_string * tags = cson_new_string("tags",4);
392392
cson_string * isLeaf = cson_new_string("isLeaf",6);
393393
cson_array * ar = cson_value_get_array(pay);
394
+ cson_object * outer = NULL;
394395
unsigned int i = 0;
395396
unsigned int len = cson_array_length_get(ar);
396397
cson_value_add_reference( cson_string_value(tags) );
397398
cson_value_add_reference( cson_string_value(isLeaf) );
398399
for( ; i < len; ++i ){
399400
cson_object * row = cson_value_get_object(cson_array_get(ar,i));
400401
int rid = cson_value_get_integer(cson_object_get(row,"rid"));
401402
assert( rid > 0 );
402403
cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0));
403
- cson_object_set_s(row, isLeaf, json_value_to_bool(cson_object_get(row,"isLeaf")));
404
+ cson_object_set_s(row, isLeaf,
405
+ json_value_to_bool(cson_object_get(row,"isLeaf")));
406
+ cson_object_set(row, "rid", NULL)
407
+ /* remove rid - we don't really want it to be public */;
404408
}
405409
cson_value_free( cson_string_value(tags) );
406410
cson_value_free( cson_string_value(isLeaf) );
411
+
412
+ /* now we wrap the payload in an outer shell, for consistency with
413
+ other /json/timeline/xyz APIs...
414
+ */
415
+ outer = cson_new_object();
416
+ if(limit>0){
417
+ cson_object_set( outer, "limit", json_new_int(limit) );
418
+ }
419
+ cson_object_set( outer, "timeline", pay );
420
+ pay = cson_object_value(outer);
407421
}
408422
return pay;
409423
}
410424
411425
/*
412426
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -389,23 +389,37 @@
389 if(pay){
390 /* get the array-form tags of each record. */
391 cson_string * tags = cson_new_string("tags",4);
392 cson_string * isLeaf = cson_new_string("isLeaf",6);
393 cson_array * ar = cson_value_get_array(pay);
 
394 unsigned int i = 0;
395 unsigned int len = cson_array_length_get(ar);
396 cson_value_add_reference( cson_string_value(tags) );
397 cson_value_add_reference( cson_string_value(isLeaf) );
398 for( ; i < len; ++i ){
399 cson_object * row = cson_value_get_object(cson_array_get(ar,i));
400 int rid = cson_value_get_integer(cson_object_get(row,"rid"));
401 assert( rid > 0 );
402 cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0));
403 cson_object_set_s(row, isLeaf, json_value_to_bool(cson_object_get(row,"isLeaf")));
 
 
 
404 }
405 cson_value_free( cson_string_value(tags) );
406 cson_value_free( cson_string_value(isLeaf) );
 
 
 
 
 
 
 
 
 
 
407 }
408 return pay;
409 }
410
411 /*
412
--- src/json_timeline.c
+++ src/json_timeline.c
@@ -389,23 +389,37 @@
389 if(pay){
390 /* get the array-form tags of each record. */
391 cson_string * tags = cson_new_string("tags",4);
392 cson_string * isLeaf = cson_new_string("isLeaf",6);
393 cson_array * ar = cson_value_get_array(pay);
394 cson_object * outer = NULL;
395 unsigned int i = 0;
396 unsigned int len = cson_array_length_get(ar);
397 cson_value_add_reference( cson_string_value(tags) );
398 cson_value_add_reference( cson_string_value(isLeaf) );
399 for( ; i < len; ++i ){
400 cson_object * row = cson_value_get_object(cson_array_get(ar,i));
401 int rid = cson_value_get_integer(cson_object_get(row,"rid"));
402 assert( rid > 0 );
403 cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0));
404 cson_object_set_s(row, isLeaf,
405 json_value_to_bool(cson_object_get(row,"isLeaf")));
406 cson_object_set(row, "rid", NULL)
407 /* remove rid - we don't really want it to be public */;
408 }
409 cson_value_free( cson_string_value(tags) );
410 cson_value_free( cson_string_value(isLeaf) );
411
412 /* now we wrap the payload in an outer shell, for consistency with
413 other /json/timeline/xyz APIs...
414 */
415 outer = cson_new_object();
416 if(limit>0){
417 cson_object_set( outer, "limit", json_new_int(limit) );
418 }
419 cson_object_set( outer, "timeline", pay );
420 pay = cson_object_value(outer);
421 }
422 return pay;
423 }
424
425 /*
426

Keyboard Shortcuts

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