aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-03-01 21:24:58 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-03-01 21:43:04 -0800
commit0c7039de0e22587913e23988a4e2d6c06fd3bb34 (patch)
tree62a9372254418f7f87bd422583bb2fce903df939 /storage
parentf110384f113002ad022c677ea138a0f77fad4a62 (diff)
Entries date should contains user timezone (API)
Diffstat (limited to 'storage')
-rw-r--r--storage/entry_query_builder.go10
-rw-r--r--storage/feed.go13
2 files changed, 20 insertions, 3 deletions
diff --git a/storage/entry_query_builder.go b/storage/entry_query_builder.go
index 7c8d924..6650dbb 100644
--- a/storage/entry_query_builder.go
+++ b/storage/entry_query_builder.go
@@ -13,6 +13,7 @@ import (
"github.com/miniflux/miniflux/model"
"github.com/miniflux/miniflux/timer"
+ "github.com/miniflux/miniflux/timezone"
)
// EntryQueryBuilder builds a SQL query to fetch entries.
@@ -160,7 +161,8 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) {
e.url, e.author, e.content, e.status, e.starred,
f.title as feed_title, f.feed_url, f.site_url, f.checked_at,
f.category_id, c.title as category_title, f.scraper_rules, f.rewrite_rules, f.crawler,
- fi.icon_id
+ fi.icon_id,
+ u.timezone
FROM entries e
LEFT JOIN feeds f ON f.id=e.feed_id
LEFT JOIN categories c ON c.id=f.category_id
@@ -183,6 +185,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) {
for rows.Next() {
var entry model.Entry
var iconID interface{}
+ var tz string
entry.Feed = &model.Feed{UserID: e.userID}
entry.Feed.Category = &model.Category{UserID: e.userID}
@@ -210,6 +213,7 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) {
&entry.Feed.RewriteRules,
&entry.Feed.Crawler,
&iconID,
+ &tz,
)
if err != nil {
@@ -222,6 +226,10 @@ func (e *EntryQueryBuilder) GetEntries() (model.Entries, error) {
entry.Feed.Icon.IconID = iconID.(int64)
}
+ // Make sure that timestamp fields contains timezone information (API)
+ entry.Date = timezone.Convert(tz, entry.Date)
+ entry.Feed.CheckedAt = timezone.Convert(tz, entry.Feed.CheckedAt)
+
entry.Feed.ID = entry.FeedID
entry.Feed.Icon.FeedID = entry.FeedID
entries = append(entries, &entry)
diff --git a/storage/feed.go b/storage/feed.go
index 87b234a..7aa78b0 100644
--- a/storage/feed.go
+++ b/storage/feed.go
@@ -12,6 +12,7 @@ import (
"github.com/miniflux/miniflux/model"
"github.com/miniflux/miniflux/timer"
+ "github.com/miniflux/miniflux/timezone"
)
// FeedExists checks if the given feed exists.
@@ -56,7 +57,8 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
f.parsing_error_count, f.parsing_error_msg,
f.scraper_rules, f.rewrite_rules, f.crawler,
f.category_id, c.title as category_title,
- fi.icon_id
+ fi.icon_id,
+ u.timezone
FROM feeds f
LEFT JOIN categories c ON c.id=f.category_id
LEFT JOIN feed_icons fi ON fi.feed_id=f.id
@@ -73,6 +75,7 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
for rows.Next() {
var feed model.Feed
var iconID interface{}
+ var tz string
feed.Category = &model.Category{UserID: userID}
err := rows.Scan(
@@ -92,6 +95,7 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
&feed.Category.ID,
&feed.Category.Title,
&iconID,
+ &tz,
)
if err != nil {
@@ -102,6 +106,7 @@ func (s *Storage) Feeds(userID int64) (model.Feeds, error) {
feed.Icon = &model.FeedIcon{FeedID: feed.ID, IconID: iconID.(int64)}
}
+ feed.CheckedAt = timezone.Convert(tz, feed.CheckedAt)
feeds = append(feeds, &feed)
}
@@ -114,6 +119,7 @@ func (s *Storage) FeedByID(userID, feedID int64) (*model.Feed, error) {
var feed model.Feed
var iconID interface{}
+ var tz string
feed.Category = &model.Category{UserID: userID}
query := `
@@ -123,7 +129,8 @@ func (s *Storage) FeedByID(userID, feedID int64) (*model.Feed, error) {
f.parsing_error_count, f.parsing_error_msg,
f.scraper_rules, f.rewrite_rules, f.crawler,
f.category_id, c.title as category_title,
- fi.icon_id
+ fi.icon_id,
+ u.timezone
FROM feeds f
LEFT JOIN categories c ON c.id=f.category_id
LEFT JOIN feed_icons fi ON fi.feed_id=f.id
@@ -147,6 +154,7 @@ func (s *Storage) FeedByID(userID, feedID int64) (*model.Feed, error) {
&feed.Category.ID,
&feed.Category.Title,
&iconID,
+ &tz,
)
switch {
@@ -160,6 +168,7 @@ func (s *Storage) FeedByID(userID, feedID int64) (*model.Feed, error) {
feed.Icon = &model.FeedIcon{FeedID: feed.ID, IconID: iconID.(int64)}
}
+ feed.CheckedAt = timezone.Convert(tz, feed.CheckedAt)
return &feed, nil
}