Fossil SCM
removed some dead code, minor internal cleanups in /json/timeline.
Commit
6420654c806b93b6fed4341c748ae8da1317a96f
Parent
648e74d857fc4b5…
1 file changed
+12
-26
+12
-26
| --- src/json_timeline.c | ||
| +++ src/json_timeline.c | ||
| @@ -135,11 +135,11 @@ | ||
| 135 | 135 | ** to. |
| 136 | 136 | ** |
| 137 | 137 | ** Returns a positive value if it modifies pSql, 0 if it |
| 138 | 138 | ** does not. It returns a negative value if the tag |
| 139 | 139 | ** provided to the request was not found (pSql is not modified |
| 140 | -** in that case. | |
| 140 | +** in that case). | |
| 141 | 141 | ** |
| 142 | 142 | ** If payload is not NULL then on success its "tag" or "branch" |
| 143 | 143 | ** property is set to the tag/branch name found in the request. |
| 144 | 144 | ** |
| 145 | 145 | ** Only one of "tag" or "branch" modes will work at a time, and if |
| @@ -233,12 +233,11 @@ | ||
| 233 | 233 | ** environment parameters. If it can it returns that value, |
| 234 | 234 | ** else it returns some statically defined default value. |
| 235 | 235 | ** |
| 236 | 236 | ** Never returns a negative value. 0 means no limit. |
| 237 | 237 | */ |
| 238 | -static int json_timeline_limit(){ | |
| 239 | - static const int defaultLimit = 20; | |
| 238 | +static int json_timeline_limit(int defaultLimit){ | |
| 240 | 239 | int limit = -1; |
| 241 | 240 | if(!g.isHTTP){/* CLI mode */ |
| 242 | 241 | char const * arg = find_option("limit","n",1); |
| 243 | 242 | if(arg && *arg){ |
| 244 | 243 | limit = atoi(arg); |
| @@ -275,12 +274,12 @@ | ||
| 275 | 274 | blob_appendf(pSql, " AND event.type IN(%Q) ", zEventType); |
| 276 | 275 | if( json_timeline_add_tag_branch_clause(pSql, pPayload) < 0 ){ |
| 277 | 276 | return FSL_JSON_E_INVALID_ARGS; |
| 278 | 277 | } |
| 279 | 278 | json_timeline_add_time_clause(pSql); |
| 280 | - limit = json_timeline_limit(); | |
| 281 | - if(limit>=0){ | |
| 279 | + limit = json_timeline_limit(20); | |
| 280 | + if(limit>0){ | |
| 282 | 281 | blob_appendf(pSql,"LIMIT %d ",limit); |
| 283 | 282 | } |
| 284 | 283 | if(pPayload){ |
| 285 | 284 | cson_object_set(pPayload, "limit", json_new_int(limit)); |
| 286 | 285 | } |
| @@ -353,10 +352,11 @@ | ||
| 353 | 352 | |
| 354 | 353 | static cson_value * json_timeline_branch(){ |
| 355 | 354 | cson_value * pay = NULL; |
| 356 | 355 | Blob sql = empty_blob; |
| 357 | 356 | Stmt q = empty_Stmt; |
| 357 | + int limit = 0; | |
| 358 | 358 | if(!g.perm.Read){ |
| 359 | 359 | json_set_err(FSL_JSON_E_DENIED, |
| 360 | 360 | "Requires 'o' permissions."); |
| 361 | 361 | return NULL; |
| 362 | 362 | } |
| @@ -378,10 +378,14 @@ | ||
| 378 | 378 | " AND event.type='ci'" |
| 379 | 379 | " AND blob.rid IN (SELECT rid FROM tagxref" |
| 380 | 380 | " WHERE tagtype>0 AND tagid=%d AND srcid!=0)" |
| 381 | 381 | " ORDER BY event.mtime DESC", |
| 382 | 382 | TAG_BRANCH); |
| 383 | + limit = json_timeline_limit(20); | |
| 384 | + if(limit>0){ | |
| 385 | + blob_appendf(&sql," LIMIT %d ",limit); | |
| 386 | + } | |
| 383 | 387 | db_prepare(&q,"%s", blob_str(&sql)); |
| 384 | 388 | blob_reset(&sql); |
| 385 | 389 | pay = json_stmt_to_array_of_obj(&q, NULL); |
| 386 | 390 | db_finalize(&q); |
| 387 | 391 | assert(NULL != pay); |
| @@ -395,14 +399,13 @@ | ||
| 395 | 399 | unsigned int i = 0; |
| 396 | 400 | unsigned int len = cson_array_length_get(ar); |
| 397 | 401 | for( ; i < len; ++i ){ |
| 398 | 402 | cson_object * row = cson_value_get_object(cson_array_get(ar,i)); |
| 399 | 403 | int rid = cson_value_get_integer(cson_object_get(row,"rid")); |
| 400 | - if(row>0) { | |
| 401 | - cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0)); | |
| 402 | - cson_object_set_s(row, isLeaf, json_value_to_bool(cson_object_get(row,"isLeaf"))); | |
| 403 | - } | |
| 404 | + assert( rid > 0 ); | |
| 405 | + cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0)); | |
| 406 | + cson_object_set_s(row, isLeaf, json_value_to_bool(cson_object_get(row,"isLeaf"))); | |
| 404 | 407 | } |
| 405 | 408 | cson_value_free( cson_string_value(tags) ); |
| 406 | 409 | cson_value_free( cson_string_value(isLeaf) ); |
| 407 | 410 | } |
| 408 | 411 | return pay; |
| @@ -454,27 +457,10 @@ | ||
| 454 | 457 | #endif |
| 455 | 458 | db_multi_exec(blob_buffer(&sql)); |
| 456 | 459 | blob_reset(&sql); |
| 457 | 460 | db_prepare(&q, "SELECT " |
| 458 | 461 | " rid AS rid" |
| 459 | -#if 0 | |
| 460 | - " uuid AS uuid," | |
| 461 | - " mtime AS timestamp," | |
| 462 | -# if 0 | |
| 463 | - " timestampString AS timestampString," | |
| 464 | -# endif | |
| 465 | - " comment AS comment, " | |
| 466 | - " user AS user," | |
| 467 | - " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */ | |
| 468 | - " bgColor AS bgColor," /* why always null? */ | |
| 469 | - " eventType AS eventType" | |
| 470 | -# if 0 | |
| 471 | - " tags AS tags" | |
| 472 | - /*tagId is always null?*/ | |
| 473 | - " tagId AS tagId" | |
| 474 | -# endif | |
| 475 | -#endif | |
| 476 | 462 | " FROM json_timeline" |
| 477 | 463 | " ORDER BY rowid"); |
| 478 | 464 | listV = cson_value_new_array(); |
| 479 | 465 | list = cson_value_get_array(listV); |
| 480 | 466 | tmp = listV; |
| 481 | 467 |
| --- src/json_timeline.c | |
| +++ src/json_timeline.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | ** to. |
| 136 | ** |
| 137 | ** Returns a positive value if it modifies pSql, 0 if it |
| 138 | ** does not. It returns a negative value if the tag |
| 139 | ** provided to the request was not found (pSql is not modified |
| 140 | ** in that case. |
| 141 | ** |
| 142 | ** If payload is not NULL then on success its "tag" or "branch" |
| 143 | ** property is set to the tag/branch name found in the request. |
| 144 | ** |
| 145 | ** Only one of "tag" or "branch" modes will work at a time, and if |
| @@ -233,12 +233,11 @@ | |
| 233 | ** environment parameters. If it can it returns that value, |
| 234 | ** else it returns some statically defined default value. |
| 235 | ** |
| 236 | ** Never returns a negative value. 0 means no limit. |
| 237 | */ |
| 238 | static int json_timeline_limit(){ |
| 239 | static const int defaultLimit = 20; |
| 240 | int limit = -1; |
| 241 | if(!g.isHTTP){/* CLI mode */ |
| 242 | char const * arg = find_option("limit","n",1); |
| 243 | if(arg && *arg){ |
| 244 | limit = atoi(arg); |
| @@ -275,12 +274,12 @@ | |
| 275 | blob_appendf(pSql, " AND event.type IN(%Q) ", zEventType); |
| 276 | if( json_timeline_add_tag_branch_clause(pSql, pPayload) < 0 ){ |
| 277 | return FSL_JSON_E_INVALID_ARGS; |
| 278 | } |
| 279 | json_timeline_add_time_clause(pSql); |
| 280 | limit = json_timeline_limit(); |
| 281 | if(limit>=0){ |
| 282 | blob_appendf(pSql,"LIMIT %d ",limit); |
| 283 | } |
| 284 | if(pPayload){ |
| 285 | cson_object_set(pPayload, "limit", json_new_int(limit)); |
| 286 | } |
| @@ -353,10 +352,11 @@ | |
| 353 | |
| 354 | static cson_value * json_timeline_branch(){ |
| 355 | cson_value * pay = NULL; |
| 356 | Blob sql = empty_blob; |
| 357 | Stmt q = empty_Stmt; |
| 358 | if(!g.perm.Read){ |
| 359 | json_set_err(FSL_JSON_E_DENIED, |
| 360 | "Requires 'o' permissions."); |
| 361 | return NULL; |
| 362 | } |
| @@ -378,10 +378,14 @@ | |
| 378 | " AND event.type='ci'" |
| 379 | " AND blob.rid IN (SELECT rid FROM tagxref" |
| 380 | " WHERE tagtype>0 AND tagid=%d AND srcid!=0)" |
| 381 | " ORDER BY event.mtime DESC", |
| 382 | TAG_BRANCH); |
| 383 | db_prepare(&q,"%s", blob_str(&sql)); |
| 384 | blob_reset(&sql); |
| 385 | pay = json_stmt_to_array_of_obj(&q, NULL); |
| 386 | db_finalize(&q); |
| 387 | assert(NULL != pay); |
| @@ -395,14 +399,13 @@ | |
| 395 | unsigned int i = 0; |
| 396 | unsigned int len = cson_array_length_get(ar); |
| 397 | for( ; i < len; ++i ){ |
| 398 | cson_object * row = cson_value_get_object(cson_array_get(ar,i)); |
| 399 | int rid = cson_value_get_integer(cson_object_get(row,"rid")); |
| 400 | if(row>0) { |
| 401 | cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0)); |
| 402 | cson_object_set_s(row, isLeaf, json_value_to_bool(cson_object_get(row,"isLeaf"))); |
| 403 | } |
| 404 | } |
| 405 | cson_value_free( cson_string_value(tags) ); |
| 406 | cson_value_free( cson_string_value(isLeaf) ); |
| 407 | } |
| 408 | return pay; |
| @@ -454,27 +457,10 @@ | |
| 454 | #endif |
| 455 | db_multi_exec(blob_buffer(&sql)); |
| 456 | blob_reset(&sql); |
| 457 | db_prepare(&q, "SELECT " |
| 458 | " rid AS rid" |
| 459 | #if 0 |
| 460 | " uuid AS uuid," |
| 461 | " mtime AS timestamp," |
| 462 | # if 0 |
| 463 | " timestampString AS timestampString," |
| 464 | # endif |
| 465 | " comment AS comment, " |
| 466 | " user AS user," |
| 467 | " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */ |
| 468 | " bgColor AS bgColor," /* why always null? */ |
| 469 | " eventType AS eventType" |
| 470 | # if 0 |
| 471 | " tags AS tags" |
| 472 | /*tagId is always null?*/ |
| 473 | " tagId AS tagId" |
| 474 | # endif |
| 475 | #endif |
| 476 | " FROM json_timeline" |
| 477 | " ORDER BY rowid"); |
| 478 | listV = cson_value_new_array(); |
| 479 | list = cson_value_get_array(listV); |
| 480 | tmp = listV; |
| 481 |
| --- src/json_timeline.c | |
| +++ src/json_timeline.c | |
| @@ -135,11 +135,11 @@ | |
| 135 | ** to. |
| 136 | ** |
| 137 | ** Returns a positive value if it modifies pSql, 0 if it |
| 138 | ** does not. It returns a negative value if the tag |
| 139 | ** provided to the request was not found (pSql is not modified |
| 140 | ** in that case). |
| 141 | ** |
| 142 | ** If payload is not NULL then on success its "tag" or "branch" |
| 143 | ** property is set to the tag/branch name found in the request. |
| 144 | ** |
| 145 | ** Only one of "tag" or "branch" modes will work at a time, and if |
| @@ -233,12 +233,11 @@ | |
| 233 | ** environment parameters. If it can it returns that value, |
| 234 | ** else it returns some statically defined default value. |
| 235 | ** |
| 236 | ** Never returns a negative value. 0 means no limit. |
| 237 | */ |
| 238 | static int json_timeline_limit(int defaultLimit){ |
| 239 | int limit = -1; |
| 240 | if(!g.isHTTP){/* CLI mode */ |
| 241 | char const * arg = find_option("limit","n",1); |
| 242 | if(arg && *arg){ |
| 243 | limit = atoi(arg); |
| @@ -275,12 +274,12 @@ | |
| 274 | blob_appendf(pSql, " AND event.type IN(%Q) ", zEventType); |
| 275 | if( json_timeline_add_tag_branch_clause(pSql, pPayload) < 0 ){ |
| 276 | return FSL_JSON_E_INVALID_ARGS; |
| 277 | } |
| 278 | json_timeline_add_time_clause(pSql); |
| 279 | limit = json_timeline_limit(20); |
| 280 | if(limit>0){ |
| 281 | blob_appendf(pSql,"LIMIT %d ",limit); |
| 282 | } |
| 283 | if(pPayload){ |
| 284 | cson_object_set(pPayload, "limit", json_new_int(limit)); |
| 285 | } |
| @@ -353,10 +352,11 @@ | |
| 352 | |
| 353 | static cson_value * json_timeline_branch(){ |
| 354 | cson_value * pay = NULL; |
| 355 | Blob sql = empty_blob; |
| 356 | Stmt q = empty_Stmt; |
| 357 | int limit = 0; |
| 358 | if(!g.perm.Read){ |
| 359 | json_set_err(FSL_JSON_E_DENIED, |
| 360 | "Requires 'o' permissions."); |
| 361 | return NULL; |
| 362 | } |
| @@ -378,10 +378,14 @@ | |
| 378 | " AND event.type='ci'" |
| 379 | " AND blob.rid IN (SELECT rid FROM tagxref" |
| 380 | " WHERE tagtype>0 AND tagid=%d AND srcid!=0)" |
| 381 | " ORDER BY event.mtime DESC", |
| 382 | TAG_BRANCH); |
| 383 | limit = json_timeline_limit(20); |
| 384 | if(limit>0){ |
| 385 | blob_appendf(&sql," LIMIT %d ",limit); |
| 386 | } |
| 387 | db_prepare(&q,"%s", blob_str(&sql)); |
| 388 | blob_reset(&sql); |
| 389 | pay = json_stmt_to_array_of_obj(&q, NULL); |
| 390 | db_finalize(&q); |
| 391 | assert(NULL != pay); |
| @@ -395,14 +399,13 @@ | |
| 399 | unsigned int i = 0; |
| 400 | unsigned int len = cson_array_length_get(ar); |
| 401 | for( ; i < len; ++i ){ |
| 402 | cson_object * row = cson_value_get_object(cson_array_get(ar,i)); |
| 403 | int rid = cson_value_get_integer(cson_object_get(row,"rid")); |
| 404 | assert( rid > 0 ); |
| 405 | cson_object_set_s(row, tags, json_tags_for_checkin_rid(rid,0)); |
| 406 | cson_object_set_s(row, isLeaf, json_value_to_bool(cson_object_get(row,"isLeaf"))); |
| 407 | } |
| 408 | cson_value_free( cson_string_value(tags) ); |
| 409 | cson_value_free( cson_string_value(isLeaf) ); |
| 410 | } |
| 411 | return pay; |
| @@ -454,27 +457,10 @@ | |
| 457 | #endif |
| 458 | db_multi_exec(blob_buffer(&sql)); |
| 459 | blob_reset(&sql); |
| 460 | db_prepare(&q, "SELECT " |
| 461 | " rid AS rid" |
| 462 | " FROM json_timeline" |
| 463 | " ORDER BY rowid"); |
| 464 | listV = cson_value_new_array(); |
| 465 | list = cson_value_get_array(listV); |
| 466 | tmp = listV; |
| 467 |