Hi all,
I put together a quick external script to do full-text searches on
tickets. It's not anything complicated, just creates a sqlite fts table
and dumps all the ticket info into it, which means that it doesn't
update automatically when tickets are updated. Still, I've found it
useful, so I'm sharing it in case anyone else does.
The nice thing is that fossil doesn't care if there are other tables in
the database, so nothing changes from fossil's perspective.
-J
PS: I've included the script as an attachment, if the mailing list
strips that I'll resend or share it somewhere else.
#!/usr/bin/env tclsh8.6
package require sqlite3
set fsl [lindex $argv 0]
set search [lindex $argv 1]
sqlite db $fsl
# set baseurl [db eval {select value from config where name = 'last-sync-url'}]
if {[db eval {select count(*) from sqlite_master where tbl_name =
'ticket_search'}] == 0} {
puts "creating index"
db eval {
create virtual table if not exists ticket_search using fts4(tkt_uuid,
subsystem, title, comment);
}
}
set count [db eval {
select count(*) from ticket
where tkt_uuid not in (select tkt_uuid from ticket_search)
}]
if {$count > 0} {
puts "indexing $count new tickets"
db eval {
insert into ticket_search
select tkt_uuid, subsystem, title, comment from ticket
where tkt_uuid not in (select tkt_uuid from ticket_search)
}
}
puts "scanning"
puts [format "%12.12s %-15.15s %s" "Ticket UUID" "Subsystem" "Title"]
db eval {
select distinct tkt_uuid, subsystem, title from ticket_search where
ticket_search match $search
} row {
# puts [format "${baseurl}info/%12.12s %-15.15s %s" $row(tkt_uuid)
$row(subsystem) $row(title)]
puts [format "%12.12s %-15.15s %s" $row(tkt_uuid) $row(subsystem)
$row(title)]
}
_______________________________________________
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users