diff options
author | 2023-02-25 04:52:45 +0000 | |
---|---|---|
committer | 2023-02-24 20:52:45 -0800 | |
commit | 8f9ccc6540be9d637b812985936f064bada8fcf3 (patch) | |
tree | 7d098af52e1f8946c1cd26ee214307b276b5f273 /storage/entry_query_builder.go | |
parent | ff8d68c151645de62d48fba62d2f591eab8f7383 (diff) | |
download | v2-8f9ccc6540be9d637b812985936f064bada8fcf3.tar.gz v2-8f9ccc6540be9d637b812985936f064bada8fcf3.tar.zst v2-8f9ccc6540be9d637b812985936f064bada8fcf3.zip |
Parse `<category>` from Feeds (RSS, Atom and JSON)
Diffstat (limited to '')
-rw-r--r-- | storage/entry_query_builder.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/storage/entry_query_builder.go b/storage/entry_query_builder.go index 437e769c..dae7bc1f 100644 --- a/storage/entry_query_builder.go +++ b/storage/entry_query_builder.go @@ -135,6 +135,17 @@ func (e *EntryQueryBuilder) WithStatuses(statuses []string) *EntryQueryBuilder { return e } +// WithTags filter by a list of entry tags. +func (e *EntryQueryBuilder) WithTags(tags []string) *EntryQueryBuilder { + if len(tags) > 0 { + for _, cat := range tags { + e.conditions = append(e.conditions, fmt.Sprintf("$%d = ANY(e.tags)", len(e.args)+1)) + e.args = append(e.args, cat) + } + } + return e +} + // WithoutStatus set the entry status that should not be returned. func (e *EntryQueryBuilder) WithoutStatus(status string) *EntryQueryBuilder { if status != "" { @@ -250,6 +261,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) { e.reading_time, e.created_at, e.changed_at, + e.tags, f.title as feed_title, f.feed_url, f.site_url, @@ -312,6 +324,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) { &entry.ReadingTime, &entry.CreatedAt, &entry.ChangedAt, + pq.Array(&entry.Tags), &entry.Feed.Title, &entry.Feed.FeedURL, &entry.Feed.SiteURL, |