From 23d2cfe0f98f3d6acc04ef11653d3dbaf0b0b677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Guillot?= Date: Tue, 17 Oct 2023 17:56:17 -0700 Subject: [PATCH] Expose `next_check_at` in the web ui and API --- internal/locale/translations/de_DE.json | 1 + internal/locale/translations/el_EL.json | 1 + internal/locale/translations/en_US.json | 1 + internal/locale/translations/es_ES.json | 1 + internal/locale/translations/fi_FI.json | 1 + internal/locale/translations/fr_FR.json | 1 + internal/locale/translations/hi_IN.json | 1 + internal/locale/translations/id_ID.json | 1 + internal/locale/translations/it_IT.json | 1 + internal/locale/translations/ja_JP.json | 1 + internal/locale/translations/nl_NL.json | 1 + internal/locale/translations/pl_PL.json | 1 + internal/locale/translations/pt_BR.json | 1 + internal/locale/translations/ru_RU.json | 1 + internal/locale/translations/tr_TR.json | 1 + internal/locale/translations/uk_UA.json | 1 + internal/locale/translations/zh_CN.json | 1 + internal/locale/translations/zh_TW.json | 1 + internal/storage/feed_query_builder.go | 3 +++ internal/template/functions.go | 18 +++++++++++++++++- .../template/templates/common/feed_list.html | 6 ++++++ .../template/templates/views/edit_feed.html | 4 ++++ 22 files changed, 48 insertions(+), 1 deletion(-) diff --git a/internal/locale/translations/de_DE.json b/internal/locale/translations/de_DE.json index ef3b201d..a30107c2 100644 --- a/internal/locale/translations/de_DE.json +++ b/internal/locale/translations/de_DE.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Benutzer bearbeiten: %s", "page.feeds.title": "Abonnements", "page.feeds.last_check": "Letzte Aktualisierung:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Anzahl der ungelesenen Artikel", "page.feeds.read_counter": "Anzahl der gelesenen Artikel", "page.feeds.error_count": [ diff --git a/internal/locale/translations/el_EL.json b/internal/locale/translations/el_EL.json index 6ee849f5..1110afea 100644 --- a/internal/locale/translations/el_EL.json +++ b/internal/locale/translations/el_EL.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Επεξεργασία χρήστη: % s", "page.feeds.title": "Ροές", "page.feeds.last_check": "Τελευταίος έλεγχος:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Αριθμός μη αναγνωσμένων καταχωρήσεων", "page.feeds.read_counter": "Αριθμός αναγνωσμένων καταχωρήσεων", "page.feeds.error_count": [ diff --git a/internal/locale/translations/en_US.json b/internal/locale/translations/en_US.json index 0ac44b48..155bc8ac 100644 --- a/internal/locale/translations/en_US.json +++ b/internal/locale/translations/en_US.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Edit User: %s", "page.feeds.title": "Feeds", "page.feeds.last_check": "Last check:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Number of unread entries", "page.feeds.read_counter": "Number of read entries", "page.feeds.error_count": [ diff --git a/internal/locale/translations/es_ES.json b/internal/locale/translations/es_ES.json index 596b966a..fb28dce6 100644 --- a/internal/locale/translations/es_ES.json +++ b/internal/locale/translations/es_ES.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Editar usuario: %s", "page.feeds.title": "Fuentes", "page.feeds.last_check": "Última verificación:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Número de artículos no leídos", "page.feeds.read_counter": "Número de artículos leídos", "page.feeds.error_count": [ diff --git a/internal/locale/translations/fi_FI.json b/internal/locale/translations/fi_FI.json index 07573a06..b4dcd044 100644 --- a/internal/locale/translations/fi_FI.json +++ b/internal/locale/translations/fi_FI.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Muokkaa käyttäjä: %s", "page.feeds.title": "Syötteet", "page.feeds.last_check": "Viimeisin tarkistus:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Lukemattomien artikkeleiden määrä", "page.feeds.read_counter": "Luettujen artikkeleiden määrä", "page.feeds.error_count": [ diff --git a/internal/locale/translations/fr_FR.json b/internal/locale/translations/fr_FR.json index 9ef51950..5db55994 100644 --- a/internal/locale/translations/fr_FR.json +++ b/internal/locale/translations/fr_FR.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Modification de l'utilisateur : %s", "page.feeds.title": "Abonnements", "page.feeds.last_check": "Dernière vérification :", + "page.feeds.next_check": "Prochaine vérification :", "page.feeds.unread_counter": "Nombre d'entrées non lues", "page.feeds.read_counter": "Nombre d'entrées lues", "page.feeds.error_count": [ diff --git a/internal/locale/translations/hi_IN.json b/internal/locale/translations/hi_IN.json index 3e63153b..b434cf39 100644 --- a/internal/locale/translations/hi_IN.json +++ b/internal/locale/translations/hi_IN.json @@ -101,6 +101,7 @@ "page.edit_user.title": "%s उपभोक्ता संपाद करे", "page.feeds.title": "फ़ीड", "page.feeds.last_check": "आखरी जाँच", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "अपठित विषयवस्तुया", "page.feeds.read_counter": "पड़े हुए विषयवस्तुया", "page.feeds.error_count": [ diff --git a/internal/locale/translations/id_ID.json b/internal/locale/translations/id_ID.json index 5bc3f575..a2b39adf 100644 --- a/internal/locale/translations/id_ID.json +++ b/internal/locale/translations/id_ID.json @@ -99,6 +99,7 @@ "page.edit_user.title": "Sunting Pengguna: %s", "page.feeds.title": "Umpan", "page.feeds.last_check": "Terakhir diperiksa:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Jumlah entri yang belum dibaca", "page.feeds.read_counter": "Jumlah entri yang telah dibaca", "page.feeds.error_count": [ diff --git a/internal/locale/translations/it_IT.json b/internal/locale/translations/it_IT.json index 205b4dd7..2f3421a0 100644 --- a/internal/locale/translations/it_IT.json +++ b/internal/locale/translations/it_IT.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Modifica utente: %s", "page.feeds.title": "Feed", "page.feeds.last_check": "Ultimo controllo:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Numero di voci non lette", "page.feeds.read_counter": "Numero di voci lette", "page.feeds.error_count": [ diff --git a/internal/locale/translations/ja_JP.json b/internal/locale/translations/ja_JP.json index 9fee440e..8063aded 100644 --- a/internal/locale/translations/ja_JP.json +++ b/internal/locale/translations/ja_JP.json @@ -101,6 +101,7 @@ "page.edit_user.title": "ユーザーを編集: %s", "page.feeds.title": "フィード一覧", "page.feeds.last_check": "最終チェック:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "未読記事の数", "page.feeds.read_counter": "既読記事の数", "page.feeds.error_count": [ diff --git a/internal/locale/translations/nl_NL.json b/internal/locale/translations/nl_NL.json index cd7795d5..94986b6f 100644 --- a/internal/locale/translations/nl_NL.json +++ b/internal/locale/translations/nl_NL.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Bewerk gebruiker: %s", "page.feeds.title": "Feeds", "page.feeds.last_check": "Laatste update:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Aantal ongelezen vermeldingen", "page.feeds.read_counter": "Aantal gelezen vermeldingen", "page.feeds.error_count": [ diff --git a/internal/locale/translations/pl_PL.json b/internal/locale/translations/pl_PL.json index cfb032ce..90474824 100644 --- a/internal/locale/translations/pl_PL.json +++ b/internal/locale/translations/pl_PL.json @@ -102,6 +102,7 @@ "page.edit_user.title": "Edytuj użytkownika: %s", "page.feeds.title": "Kanały", "page.feeds.last_check": "Ostatnia aktualizacja:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Liczba nieprzeczytanych wpisów", "page.feeds.read_counter": "Liczba przeczytanych wpisów", "page.feeds.error_count": [ diff --git a/internal/locale/translations/pt_BR.json b/internal/locale/translations/pt_BR.json index fc53b8dc..028b824a 100644 --- a/internal/locale/translations/pt_BR.json +++ b/internal/locale/translations/pt_BR.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Editar usuário: %s", "page.feeds.title": "Fontes", "page.feeds.last_check": "Última verificação:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Numero de itens não lidos", "page.feeds.read_counter": "Número de itens lidos", "page.feeds.error_count": [ diff --git a/internal/locale/translations/ru_RU.json b/internal/locale/translations/ru_RU.json index d7131ab7..ea65681e 100644 --- a/internal/locale/translations/ru_RU.json +++ b/internal/locale/translations/ru_RU.json @@ -102,6 +102,7 @@ "page.edit_user.title": "Изменить пользователя: %s", "page.feeds.title": "Подписки", "page.feeds.last_check": "Последняя проверка:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Количество непрочитанных статей", "page.feeds.read_counter": "Количество прочитанных статей", "page.feeds.error_count": [ diff --git a/internal/locale/translations/tr_TR.json b/internal/locale/translations/tr_TR.json index 630879cd..b7a3478a 100644 --- a/internal/locale/translations/tr_TR.json +++ b/internal/locale/translations/tr_TR.json @@ -101,6 +101,7 @@ "page.edit_user.title": "Kullanıcıyı Düzenle: %s", "page.feeds.title": "Beslemeler", "page.feeds.last_check": "Son kontrol:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Okunmamış iletilerin sayısı", "page.feeds.read_counter": "Okunmuş iletilerin sayısı", "page.feeds.error_count": [ diff --git a/internal/locale/translations/uk_UA.json b/internal/locale/translations/uk_UA.json index 74ce6aec..33cd0101 100644 --- a/internal/locale/translations/uk_UA.json +++ b/internal/locale/translations/uk_UA.json @@ -103,6 +103,7 @@ "page.edit_user.title": "Редагування користувача: %s", "page.feeds.title": "Стрічки", "page.feeds.last_check": "Остання перевірка:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "Кількість непрочитаних записів", "page.feeds.read_counter": "Кількість прочитаних записів", "page.feeds.error_count": [ diff --git a/internal/locale/translations/zh_CN.json b/internal/locale/translations/zh_CN.json index efc6e677..684d8140 100644 --- a/internal/locale/translations/zh_CN.json +++ b/internal/locale/translations/zh_CN.json @@ -100,6 +100,7 @@ "page.edit_user.title": "编辑用户 : %s", "page.feeds.title": "源", "page.feeds.last_check": "最后检查时间:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "未读文章数", "page.feeds.read_counter": "已读文章数", "page.feeds.error_count": [ diff --git a/internal/locale/translations/zh_TW.json b/internal/locale/translations/zh_TW.json index 805b76c1..5d689384 100644 --- a/internal/locale/translations/zh_TW.json +++ b/internal/locale/translations/zh_TW.json @@ -101,6 +101,7 @@ "page.edit_user.title": "編輯使用者 : %s", "page.feeds.title": "Feeds", "page.feeds.last_check": "最後檢查時間:", + "page.feeds.next_check": "Next check:", "page.feeds.unread_counter": "未讀文章數", "page.feeds.read_counter": "已讀文章數", "page.feeds.error_count": [ diff --git a/internal/storage/feed_query_builder.go b/internal/storage/feed_query_builder.go index 105d72cc..78b2f1bc 100644 --- a/internal/storage/feed_query_builder.go +++ b/internal/storage/feed_query_builder.go @@ -139,6 +139,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) { f.last_modified_header, f.user_id, f.checked_at at time zone u.timezone, + f.next_check_at at time zone u.timezone, f.parsing_error_count, f.parsing_error_msg, f.scraper_rules, @@ -204,6 +205,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) { &feed.LastModifiedHeader, &feed.UserID, &feed.CheckedAt, + &feed.NextCheckAt, &feed.ParsingErrorCount, &feed.ParsingErrorMsg, &feed.ScraperRules, @@ -252,6 +254,7 @@ func (f *FeedQueryBuilder) GetFeeds() (model.Feeds, error) { } feed.CheckedAt = timezone.Convert(tz, feed.CheckedAt) + feed.NextCheckAt = timezone.Convert(tz, feed.NextCheckAt) feed.Category.UserID = feed.UserID feeds = append(feeds, &feed) } diff --git a/internal/template/functions.go b/internal/template/functions.go index 97ca0f3d..f617029c 100644 --- a/internal/template/functions.go +++ b/internal/template/functions.go @@ -107,7 +107,8 @@ func (f *funcMap) Map() template.FuncMap { "nonce": func() string { return crypto.GenerateRandomStringHex(16) }, - "deRef": func(i *int) int { return *i }, + "deRef": func(i *int) int { return *i }, + "duration": duration, // These functions are overrode at runtime after the parsing. "elapsed": func(timezone string, t time.Time) string { @@ -160,6 +161,21 @@ func isEmail(str string) bool { return err == nil } +// Returns the duration in human readable format (hours and minutes). +func duration(t time.Time) string { + if t.IsZero() { + return "" + } + + diff := time.Until(t) + + if diff < 0 { + return "" + } + + return diff.String() +} + func elapsedTime(printer *locale.Printer, tz string, t time.Time) string { if t.IsZero() { return printer.Printf("time_elapsed.not_yet") diff --git a/internal/template/templates/common/feed_list.html b/internal/template/templates/common/feed_list.html index b41bcfbe..04985207 100644 --- a/internal/template/templates/common/feed_list.html +++ b/internal/template/templates/common/feed_list.html @@ -25,6 +25,12 @@
  • {{ t "page.feeds.last_check" }}
  • + {{ $nextCheckDuration := duration .NextCheckAt }} + {{ if ne $nextCheckDuration "" }} +
  • + {{ t "page.feeds.next_check" }} +
  • + {{ end }}