Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | refactored the prototype timeline code, split off completely from www version (different requirements). |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | json |
Files: | files | file ages | folders |
SHA1: |
1ecf337404e04409302f1432fa8d92f7 |
User & Date: | stephan 2011-09-21 14:42:25.854 |
Context
2011-09-21
| ||
15:22 | timeline json refactoring, fixed ordering, split tags into an Array. ... (check-in: d6cbe37b user: stephan tags: json) | |
14:42 | refactored the prototype timeline code, split off completely from www version (different requirements). ... (check-in: 1ecf3374 user: stephan tags: json) | |
2011-09-20
| ||
22:55 | added a couple FIXME notes before bed. ... (check-in: e7857845 user: stephan tags: json) | |
Changes
Changes to src/json.c.
︙ | ︙ | |||
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 | }else if( cson_value_is_bool(v) ){ return cson_value_get_bool(v) ? 1 : 0; }else{ /* we should arguably treat JSON null as 0. */ return dflt; } } /* ** /json/timeline/ci ** ** Far from complete. */ static cson_value * json_timeline_ci(unsigned int depth){ cson_value * payV = NULL; cson_object * pay = NULL; cson_value * tmp = NULL; int limit = json_getenv_int("n",10); Stmt q; Blob sql = empty_blob; if( !g.perm.Read/* && !g.perm.RdTkt && !g.perm.RdWiki*/ ){ g.json.resultCode = FSL_JSON_E_DENIED; return NULL; } if( limit < 0 ) limit = 10; | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | < < < < < | | | > | | | | | | | < | | 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 | }else if( cson_value_is_bool(v) ){ return cson_value_get_bool(v) ? 1 : 0; }else{ /* we should arguably treat JSON null as 0. */ return dflt; } } /* ** Create a temporary table suitable for storing timeline data. */ static void json_timeline_temp_table(void){ static const char zSql[] = @ CREATE TEMP TABLE IF NOT EXISTS json_timeline( @ rid INTEGER PRIMARY KEY, @ uuid TEXT, @ mtime INTEGER, @ timestampString TEXT, @ comment TEXT, @ user TEXT, @ isLeaf BOOLEAN, @ bgColor TEXT, @ eventType TEXT, @ tags TEXT, @ tagId INTEGER, @ brief TEXT @ ) ; db_multi_exec(zSql); } /* ** Return a pointer to a constant string that forms the basis ** for a timeline query for the JSON "checkin" interface. */ const char const * json_timeline_query_ci(void){ /* Field order MUST match that from json_timeline_temp_table()!!! */ static const char zBaseSql[] = @ SELECT @ blob.rid, @ uuid, @ strftime('%%s',event.mtime), @ datetime(event.mtime,'utc'), @ coalesce(ecomment, comment), @ coalesce(euser, user), @ blob.rid IN leaf, @ bgcolor, @ event.type, @ (SELECT group_concat(substr(tagname,5), ' ') FROM tag, tagxref @ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid @ AND tagxref.rid=blob.rid AND tagxref.tagtype>0), @ tagid, @ brief @ FROM event JOIN blob @ WHERE blob.rid=event.objid ; return zBaseSql; } /* ** /json/timeline/ci ** ** Far from complete. */ static cson_value * json_timeline_ci(unsigned int depth){ cson_value * payV = NULL; cson_object * pay = NULL; cson_value * tmp = NULL; int limit = json_getenv_int("n",10); Stmt q; Blob sql = empty_blob; if( !g.perm.Read/* && !g.perm.RdTkt && !g.perm.RdWiki*/ ){ g.json.resultCode = FSL_JSON_E_DENIED; return NULL; } if( limit < 0 ) limit = 10; json_timeline_temp_table(); blob_append(&sql, "INSERT OR IGNORE INTO json_timeline ", -1); blob_append(&sql, json_timeline_query_ci(), -1 ); blob_append(&sql, "AND event.type IN('ci') ", -1); blob_append(&sql, "ORDER BY mtime DESC ", -1); if(limit){ blob_appendf(&sql,"LIMIT %d ",limit); } db_multi_exec(blob_buffer(&sql)); payV = cson_value_new_object(); pay = cson_value_get_object(payV); #define SET(K) cson_object_set(pay,K,tmp) #if 1 /* only for testing! */ tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql))); SET("timelineSql"); #endif blob_reset(&sql); blob_append(&sql, "SELECT rid AS rid," " uuid AS uuid," " mtime AS timestamp," " timestampString AS timestampString," " comment AS comment, " " user AS user," " isLeaf AS isLeaf," /*FIXME: convert to JSON bool */ " bgColor AS bgColor," " eventType AS eventType," " tags AS tags," /*FIXME: split this into a JSON array*/ " tagId AS tagId," " brief AS briefText" " FROM json_timeline",-1); db_prepare(&q,blob_buffer(&sql)); tmp = NULL; cson_sqlite3_stmt_to_json(q.pStmt, &tmp, 1); db_finalize(&q); if(tmp){ cson_value * rows = cson_object_take(cson_value_get_object(tmp),"rows"); assert(NULL != rows); |
︙ | ︙ |
Changes to src/timeline.c.
︙ | ︙ | |||
736 737 738 739 740 741 742 | @ </script> } } /* ** Create a temporary table suitable for storing timeline data. */ | | | 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 | @ </script> } } /* ** Create a temporary table suitable for storing timeline data. */ static void timeline_temp_table(void){ static const char zSql[] = @ CREATE TEMP TABLE IF NOT EXISTS timeline( @ rid INTEGER PRIMARY KEY, @ uuid TEXT, @ timestamp TEXT, @ comment TEXT, @ user TEXT, |
︙ | ︙ |