Fix search query

This commit is contained in:
Radhi Fadlillah 2018-02-24 14:01:52 +07:00
parent 69e2754aa3
commit 07f0d333ec
2 changed files with 14 additions and 3 deletions

View file

@ -401,7 +401,7 @@ func (db *SQLiteDatabase) SearchBookmarks(orderLatest bool, keyword string, tags
// Create where clause for tags
if len(tags) > 0 {
whereTagClause := ` AND id IN (
SELECT DISTINCT bookmark_id FROM bookmark_tag
SELECT bookmark_id FROM bookmark_tag
WHERE tag_id IN (SELECT id FROM tag WHERE name IN (`
for _, tag := range tags {
@ -410,7 +410,8 @@ func (db *SQLiteDatabase) SearchBookmarks(orderLatest bool, keyword string, tags
}
whereTagClause = whereTagClause[:len(whereTagClause)-1]
whereTagClause += ")))"
whereTagClause += `)) GROUP BY bookmark_id HAVING COUNT(bookmark_id) >= ?)`
args = append(args, len(tags))
whereClause += whereTagClause
}

View file

@ -92,7 +92,7 @@
</a>
<p v-if="item.excerpt !== ''" class="bookmark-excerpt">{{item.excerpt}}</p>
<div v-if="item.tags.length > 0" class="bookmark-tags">
<a v-for="tag in item.tags">{{tag.name}}</a>
<a v-for="tag in item.tags" @click="searchTag(tag.name)">{{tag.name}}</a>
</div>
<div class="bookmark-menu">
<a @click="updateBookmark(item.index)">
@ -178,6 +178,16 @@
}
},
methods: {
searchTag: function (tag) {
if (this.loading) return;
var newTag = '#' + tag;
if (this.search.query.indexOf(newTag) === -1) {
this.search.query += ' ' + newTag;
this.search.query = this.search.query.trim().replace(/\s+/g, ' ');
this.loadData();
}
},
removeSearchParam: function (param) {
if (this.loading) return;
this.search.query = this.search.query.replace(param, ' ').trim().replace(/\s+/g, ' ');