Fossil

Check-in [14423f32]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:changed how /json/branch/list selects whether to look at open/all/closed branches.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | json
Files: files | file ages | folders
SHA1: 14423f32841334bca0fbed61a152d77771b66e60
User & Date: stephan 2011-09-21 18:53:34.194
Context
2011-09-21
18:55
s/branch_prepare_query/branch_prepare_list_query/g ... (check-in: 267739dd user: stephan tags: json)
18:53
changed how /json/branch/list selects whether to look at open/all/closed branches. ... (check-in: 14423f32 user: stephan tags: json)
18:20
Refactored prepareBranchStatement() to simplify its usage, get rid of ambiguous arg handling, and allow the caller to specify the priority of the all-vs-closed-vs-opened decision. Made it non-static and renamed to branch_prepare_statement() for re-use in /json/branch/list. ... (check-in: 5a81a5ea user: stephan tags: json)
Changes
Unified Diff Ignore Whitespace Patch
Changes to src/json.c.
1567
1568
1569
1570
1571
1572
1573

1574
1575

1576


1577
1578
1579
















1580
1581
1582
1583
1584
1585
1586
1587
1588
** and decide based off of that.
*/
static cson_value * json_branch_list(unsigned int depth){
  cson_value * payV = cson_value_new_object();
  cson_object * pay = cson_value_get_object(payV);
  cson_value * listV = cson_value_new_array();
  cson_array * list = cson_value_get_array(listV);

  int showAll = json_getenv_int("all",0);
  int showClosed = showAll ? 0 : json_getenv_int("closed",0);

  Stmt q;


  char const * range = showAll
    ? "all"
    : (showClosed?"closed":"open");
















  cson_object_set(pay,"range",cson_value_new_string(range,strlen(range)));
  branch_prepare_query(&q, showAll?1:(showClosed?-1:0));
  cson_object_set(pay,"branches",listV);
  while((SQLITE_ROW==db_step(&q))){
    cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0);
    if(v){
      cson_array_append(list,v);
    }else{
      json_warn(FSL_JSON_W_COL_TO_JSON_FAILED,NULL);







>


>

>
>
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

|







1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
** and decide based off of that.
*/
static cson_value * json_branch_list(unsigned int depth){
  cson_value * payV = cson_value_new_object();
  cson_object * pay = cson_value_get_object(payV);
  cson_value * listV = cson_value_new_array();
  cson_array * list = cson_value_get_array(listV);
  char const * range = NULL;
  int showAll = json_getenv_int("all",0);
  int showClosed = showAll ? 0 : json_getenv_int("closed",0);
  int which = 0;
  Stmt q;
  range = json_getenv_cstr("range");
  if(!range || !*range){
    range = showAll
      ? "all"
      : (showClosed?"closed":"open");
  }
  assert( (NULL != range) && *range );
  switch(*range){
    case 'c':
      range = "closed";
      which = -1;
      break;
    case 'a':
      range = "all";
      which = 1;
      break;
    default:
      range = "open";
      which = 0;
      break;
  };
  cson_object_set(pay,"range",cson_value_new_string(range,strlen(range)));
  branch_prepare_query(&q, which);
  cson_object_set(pay,"branches",listV);
  while((SQLITE_ROW==db_step(&q))){
    cson_value * v = cson_sqlite3_column_to_value(q.pStmt,0);
    if(v){
      cson_array_append(list,v);
    }else{
      json_warn(FSL_JSON_W_COL_TO_JSON_FAILED,NULL);