Login
Artifact [35670b157f]
Login

Artifact 35670b157f0f8a5761962778791d802f38b6fee6:


[import {test-common.th1ish}]
const App = object {
    f: [Fossil.createContext],
    opt:object{
        limit: (ARGV.flags.limit || ARGV.flags.n) || 10        
    }
}

if(!App.f.db || !App.f.db.repo){
    throw "No repository opened. Use -R=... to open a repo DB."
}

var sql = [api.Buffer 1024]
[sql.append {
    SELECT
    --  NULL AS sortId,
    -- blob.rid AS rid,
      substr(uuid,1,12) AS uuid,
    -- CAST(strftime('%s',event.mtime) AS INTEGER) AS mtime,
      datetime(event.mtime,'utc') AS timestampString,
      coalesce(euser, user) AS user,
    -- blob.rid IN leaf AS isLeaf,
    -- bgcolor AS bgColor,
      event.type AS eventType,
      (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) as tags,
    --  tagid as tagId,
      coalesce(ecomment, comment) AS comment
    --  brief as brief
     FROM event JOIN blob 
    WHERE blob.rid=event.objid
}]
//[sql.append bufTL] // bug (th1ish): appending wrongly when arg is-a Buffer

[sql.append ' ORDER BY mtime DESC']
if('integer' === typename App.opt.limit){
    [sql.append ' LIMIT ' App.opt.limit]
}

[print 'The ' App.opt.limit ' most recent timeline events for '
    App.f.db.repo ':']
[App.f.db.each object{
    sql:sql,
    mode:1,
    callback:proc(){
        (1===rowNumber) && [print [columnNames.join '\t']]
        [print [this.join '\t']]
    }
}]