Overview
SHA1 Hash: | d42adc11c8473e0d00efe377a1da8e8e3ffdea76 |
---|---|
Date: | 2009-08-29 22:54:18 |
User: | drh |
Comment: | Put the divider marks around the base check-in on ancestor and descendent timelines. |
Timelines: | ancestors | descendants | both | trunk |
Other Links: | files | ZIP archive | manifest |
Tags And Properties
- branch=trunk inherited from [a28c83647d]
- sym-trunk inherited from [a28c83647d]
Changes
[hide diffs]Modified src/timeline.c from [0ecd2849ac] to [846d5cea62].
@@ -335,10 +335,30 @@ ){ style_submenu_element(zMenuName, zMenuName, "%s", url_render(pUrl, zParam, zValue, zRemove, 0)); } + +/* +** zDate is a localtime date. Insert records into the +** "timeline" table to cause <hr> to be inserted before and after +** entries of that date. +*/ +static void timeline_add_dividers(const char *zDate){ + db_multi_exec( + "INSERT INTO timeline(rid,timestamp,etype)" + "VALUES(-1,datetime(%Q,'-1 second') || '.9','div')", + zDate + ); + db_multi_exec( + "INSERT INTO timeline(rid,timestamp,etype)" + "VALUES(-2,datetime(%Q) || '.1','div')", + zDate + ); +} + + /* ** WEBPAGE: timeline ** ** Query parameters: ** @@ -396,41 +416,54 @@ if( p_rid || d_rid ){ /* If p= or d= is present, ignore all other parameters other than n= */ char *zUuid; int np, nd; - if( p_rid && d_rid && p_rid!=d_rid ) p_rid = d_rid; + if( p_rid && d_rid ){ + if( p_rid!=d_rid ) p_rid = d_rid; + if( P("n")==0 ) nEntry = 10; + } db_multi_exec( "CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)" ); zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", p_rid ? p_rid : d_rid); blob_appendf(&sql, " AND event.objid IN ok"); nd = 0; if( d_rid ){ - compute_descendants(d_rid, nEntry); + compute_descendants(d_rid, nEntry+1); nd = db_int(0, "SELECT count(*)-1 FROM ok"); if( nd>0 ){ db_multi_exec("%s", blob_str(&sql)); blob_appendf(&desc, "%d descendants", nd); } + timeline_add_dividers( + db_text("1","SELECT datetime(mtime,'localtime') FROM event" + " WHERE objid=%d", d_rid) + ); db_multi_exec("DELETE FROM ok"); } if( p_rid ){ - compute_ancestors(p_rid, nEntry); + compute_ancestors(p_rid, nEntry+1); np = db_int(0, "SELECT count(*)-1 FROM ok"); if( np>0 ){ if( nd>0 ) blob_appendf(&desc, " and "); blob_appendf(&desc, "%d ancestors", np); db_multi_exec("%s", blob_str(&sql)); } + if( d_rid==0 ){ + timeline_add_dividers( + db_text("1","SELECT datetime(mtime,'localtime') FROM event" + " WHERE objid=%d", p_rid) + ); + } } if( g.okHistory ){ blob_appendf(&desc, " of <a href='%s/info/%s'>[%.10s]</a>", g.zBaseURL, zUuid, zUuid); }else{ - blob_appendf(&desc, " of [%.10s]", zUuid); + blob_appendf(&desc, " of check-in [%.10s]", zUuid); } }else{ int n; const char *zEType = "event"; char *zDate; @@ -495,20 +528,11 @@ blob_appendf(&sql, " AND event.mtime>=%f ORDER BY event.mtime ASC", rCirca ); nEntry -= (nEntry+1)/2; - db_multi_exec( - "INSERT INTO timeline(rid,timestamp,etype)" - "VALUES(-1,datetime(%Q,'-1 second') || '.9','div')", - zCirca - ); - db_multi_exec( - "INSERT INTO timeline(rid,timestamp,etype)" - "VALUES(-2,datetime(%Q) || '.1','div')", - zCirca - ); + timeline_add_dividers(zCirca); url_add_parameter(&url, "c", zCirca); }else{ zCirca = 0; } }else{