fix buggy call to instr
This commit is contained in:
parent
24613ea424
commit
c2c89b6dfd
@ -36,7 +36,9 @@
|
|||||||
[[:buffer
|
[[:buffer
|
||||||
Buffer.match
|
Buffer.match
|
||||||
#$1.buffer.name]
|
#$1.buffer.name]
|
||||||
[:url #{$1 $1} #($1.buffer:location)]
|
[:url
|
||||||
|
(fn [term] (collect [v (_G.history:find term)] (values v.url v.url)))
|
||||||
|
#($1.buffer:location)]
|
||||||
]
|
]
|
||||||
(fn [{:url url :buffer buffer}]
|
(fn [{:url url :buffer buffer}]
|
||||||
(buffer:visit url)))
|
(buffer:visit url)))
|
||||||
|
@ -37,9 +37,9 @@
|
|||||||
(s:reset)))
|
(s:reset)))
|
||||||
|
|
||||||
(fn find [self term]
|
(fn find [self term]
|
||||||
(let [s (self.db:prepare "select v.url,pt.title,v.timestamp from visits v left join page_titles pt on v.url = pt.url where instr(v.url, ?) is not null")]
|
(let [s (self.db:prepare "select v.url,pt.title,v.timestamp from visits v left join page_titles pt on v.url = pt.url where instr(v.url, ?) >0")]
|
||||||
(assert (= 0 (s:bind_values term)))
|
(assert (= 0 (s:bind_values term)))
|
||||||
(icollect [r (s:nrows)] r)))
|
(s:nrows)))
|
||||||
|
|
||||||
(fn open [pathname]
|
(fn open [pathname]
|
||||||
(let [db (if pathname (sqlite.open pathname) (sqlite.open_memory))]
|
(let [db (if pathname (sqlite.open pathname) (sqlite.open_memory))]
|
||||||
|
@ -11,15 +11,28 @@
|
|||||||
|
|
||||||
(let [h (history.open)]
|
(let [h (history.open)]
|
||||||
(h:visit "http://example.com" (fake-time))
|
(h:visit "http://example.com" (fake-time))
|
||||||
(let [actual (h:find "example.com")]
|
(assert
|
||||||
(match actual
|
(accumulate [found false
|
||||||
(where [{:url "http://example.com" :timestamp t}] (> t 0)) true
|
r (h:find "example.com")]
|
||||||
?fail (assert false (view ?fail)))))
|
(or
|
||||||
|
found
|
||||||
|
(match r
|
||||||
|
{:url "http://example.com" :timestamp t} true)))))
|
||||||
|
|
||||||
(let [h (history.open)]
|
(let [h (history.open)]
|
||||||
(h:visit "http://example.com" (fake-time))
|
(h:visit "http://example.com" (fake-time))
|
||||||
(h:title "http://example.com" "Page title")
|
(h:title "http://example.com" "Page title")
|
||||||
(let [actual (h:find "example.com")]
|
(assert
|
||||||
(match actual
|
(accumulate [found false
|
||||||
(where [{:url "http://example.com" :title "Page title" :timestamp t}] (> t 0)) true
|
r (h:find "example.com")]
|
||||||
?fail (assert false (view ?fail)))))
|
(or
|
||||||
|
found
|
||||||
|
(match r
|
||||||
|
{:url "http://example.com" :title "Page title" :timestamp t} true)))))
|
||||||
|
|
||||||
|
(let [h (history.open "/tmp/foo.db")]
|
||||||
|
(h:visit "http://example.com" (fake-time))
|
||||||
|
(h:visit "http://notsample.com" (+ 1 (fake-time)))
|
||||||
|
(each [r (h:find "example.com")]
|
||||||
|
(match r
|
||||||
|
{:url "http://notsample.com" } (assert false "unexpected row"))))
|
||||||
|
Loading…
Reference in New Issue
Block a user