aboutsummaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2018-06-16 09:55:36 -0700
committerAdam Mathes <adam@trenchant.org>2018-06-16 09:55:36 -0700
commit16df68a5118801472909f63fc48caf16e548060c (patch)
tree172e238508523db305176c4c2628d72fecc4e90c /models
parentdb331cc3382e782ba98fec33d617917fa930f3cc (diff)
downloadneko-16df68a5118801472909f63fc48caf16e548060c.tar.gz
neko-16df68a5118801472909f63fc48caf16e548060c.tar.bz2
neko-16df68a5118801472909f63fc48caf16e548060c.zip
add back in search support, requires sqlite
Diffstat (limited to 'models')
-rw-r--r--models/item/item.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/models/item/item.go b/models/item/item.go
index dd8b52c..badd566 100644
--- a/models/item/item.go
+++ b/models/item/item.go
@@ -82,7 +82,7 @@ func filterPolicy() *bluemonday.Policy {
}
func ItemById(id int64) *Item {
- items, _ := Filter(0, 0, "", false, false, id)
+ items, _ := Filter(0, 0, "", false, false, id, "")
return items[0]
}
@@ -122,17 +122,21 @@ func (i *Item) GetFullContent() {
}
}
-func Filter(max_id int64, feed_id int64, category string, unread_only bool, starred_only bool, item_id int64) ([]*Item, error) {
+func Filter(max_id int64, feed_id int64, category string, unread_only bool, starred_only bool, item_id int64, search_query string) ([]*Item, error) {
var args []interface{}
+ tables := " feed,item"
+ if search_query != "" {
+ tables = tables + ",fts_item"
+ }
query := `SELECT item.id, item.feed_id, item.title,
item.url, item.description,
item.read_state, item.starred, item.publish_date,
item.full_content, item.header_image,
feed.url, feed.title, feed.category
- FROM feed,item
- WHERE item.feed_id=feed.id AND item.id!=0 `
+ FROM `
+ query = query + tables + ` WHERE item.feed_id=feed.id AND item.id!=0 `
if max_id != 0 {
query = query + "AND item.id < ? "
@@ -158,6 +162,11 @@ func Filter(max_id int64, feed_id int64, category string, unread_only bool, star
args = append(args, item_id)
}
+ if search_query != "" {
+ query = query + " AND fts_item match ? AND fts_item.rowid=item.id "
+ args = append(args, search_query)
+ }
+
// this is kind of dumb, but to keep the logic the same
// we kludge it this way for a "by id" select
if starred_only {