Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | more consolidation of timeline/artifact code. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | json-multitag-test | json |
Files: | files | file ages | folders |
SHA1: |
cc444a02cd9cc4b3fb9aa7d4848e9386 |
User & Date: | stephan 2011-10-01 07:47:26.884 |
Context
2011-10-01
| ||
07:58 | s/commit/checkin/, for consistency. s/artifactType/type/. ... (check-in: 44e032aa user: stephan tags: json-multitag-test, json) | |
07:47 | more consolidation of timeline/artifact code. ... (check-in: cc444a02 user: stephan tags: json-multitag-test, json) | |
07:04 | more timeline/artifact refactoring. ... (check-in: 22fc0ab8 user: stephan tags: json-multitag-test, json) | |
Changes
Changes to src/json_artifact.c.
1 2 3 4 5 6 7 8 9 | #include "VERSION.h" #include "config.h" #include "json_artifact.h" #if INTERFACE #include "json_detail.h" #endif /* | | | | | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include "VERSION.h" #include "config.h" #include "json_artifact.h" #if INTERFACE #include "json_detail.h" #endif /* ** Internal callback for /json/artifact handlers. rid refers to ** the rid of a given type of artifact, and each callback is ** specialized to return a JSON form of one type of artifact. */ typedef cson_value * (*artifact_f)( int rid ); typedef struct ArtifactDispatchEntry { /** Artifact type name, e.g. "checkin". */ char const * name; /** |
︙ | ︙ | |||
33 34 35 36 37 38 39 | /* ** Generates an artifact Object for the given rid/zUuid. rid ** must refer to a Checkin. ** ** Returned value is NULL or an Object owned by the caller. */ | | | > > > > | > > > | | | | > < | > > > > > < | > > > > > | | 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | /* ** Generates an artifact Object for the given rid/zUuid. rid ** must refer to a Checkin. ** ** Returned value is NULL or an Object owned by the caller. */ cson_value * json_artifact_for_ci( int rid, char showFiles ){ char const * zParent = NULL; cson_value * v = NULL; Stmt q; static cson_value * eventTypeLabel = NULL; if(!eventTypeLabel){ eventTypeLabel = json_new_string("commit"); json_gc_add("$EVENT_TYPE_LABEL(commit)", eventTypeLabel, 1); } zParent = db_text(0, "SELECT uuid FROM plink, blob" " WHERE plink.cid=%d AND blob.rid=plink.pid AND plink.isprim", rid ); db_prepare(&q, "SELECT uuid, " " strftime('%%s',mtime), " " user, " " comment," " strftime('%%s',omtime)" " FROM blob, event" " WHERE blob.rid=%d" " AND event.objid=%d", rid, rid ); if( db_step(&q)==SQLITE_ROW ){ cson_object * o; cson_value * tmpV = NULL; v = cson_value_new_object(); o = cson_value_get_object(v); const char *zUuid = db_column_text(&q, 0); char * zTmp; const char *zUser; const char *zComment; char * zEUser, * zEComment; int mtime, omtime; #define SET(K,V) cson_object_set(o,(K), (V)) SET("artifactType", eventTypeLabel ); SET("uuid",json_new_string(zUuid)); SET("isLeaf", cson_value_new_bool(is_a_leaf(rid))); zUser = db_column_text(&q,2); zEUser = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d", TAG_USER, rid); if(zEUser){ SET("user", json_new_string(zEUser)); if(0!=strcmp(zEUser,zUser)){ SET("originUser",json_new_string(zUser)); } free(zEUser); }else{ SET("user",json_new_string(zUser)); } zComment = db_column_text(&q,3); zEComment = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d", TAG_COMMENT, rid); if(zEComment){ SET("comment",json_new_string(zEComment)); if(0 != strcmp(zEComment,zComment)){ SET("originComment", json_new_string(zComment)); } free(zEComment); }else{ SET("comment",json_new_string(zComment)); } mtime = db_column_int(&q,1); SET("mtime",json_new_int(mtime)); omtime = db_column_int(&q,4); if(omtime && (omtime!=mtime)){ SET("originTime",json_new_int(omtime)); } if(zParent){ SET("parentUuid", json_new_string(zParent)); } tmpV = json_tags_for_rid(rid); |
︙ | ︙ | |||
119 120 121 122 123 124 125 | db_finalize(&q); return v; } /* ** Sub-impl of /json/artifact for checkins. */ | | | | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | db_finalize(&q); return v; } /* ** Sub-impl of /json/artifact for checkins. */ static cson_value * json_artifact_ci( int rid ){ return json_artifact_for_ci(rid, 1); } static char perms_can_read(){ return g.perm.Read ? 1 : 0; } static ArtifactDispatchEntry ArtifactDispatchList[] = { |
︙ | ︙ | |||
222 223 224 225 226 227 228 | if(0!=strcmp(disp->name, zType)){ continue; }else{ cson_value * entry; if( ! (*disp->permCheck)() ){ break; } | | | 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 | if(0!=strcmp(disp->name, zType)){ continue; }else{ cson_value * entry; if( ! (*disp->permCheck)() ){ break; } entry = (*disp->func)(rid); if(entry){ cson_object_set(pay, "artifact", entry); } break; } } if( !disp->name ){ |
︙ | ︙ |
Changes to src/json_timeline.c.
︙ | ︙ | |||
315 316 317 318 319 320 321 | listV = cson_value_new_array(); list = cson_value_get_array(listV); tmp = listV; SET("timeline"); while( (SQLITE_ROW == db_step(&q) )){ /* convert each row into a JSON object...*/ int const rid = db_column_int(&q,0); | | | | | | | > < < < < < < < < < < < < < < < < < < < < < | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | listV = cson_value_new_array(); list = cson_value_get_array(listV); tmp = listV; SET("timeline"); while( (SQLITE_ROW == db_step(&q) )){ /* convert each row into a JSON object...*/ int const rid = db_column_int(&q,0); cson_value * rowV = json_artifact_for_ci(rid, showFiles); cson_object * row = cson_value_get_object(rowV); if(!row){ if( !warnRowToJsonFailed ){ warnRowToJsonFailed = 1; json_warn( FSL_JSON_W_ROW_TO_JSON_FAILED, "Could not convert at least one timeline result row to JSON." ); } continue; } cson_array_append(list, rowV); } #undef SET goto ok; error: assert( 0 != g.json.resultCode ); cson_value_free(payV); payV = NULL; |
︙ | ︙ |