nandi/gleanpublic⑂ Fork 0
⑂ 1e8c440
Commits
⬇ Clone ▾
git clone https://git.rickub.com/nandi/glean.git
git clone ssh://git@rickub.com/nandi/glean.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Fix show unread article on articles pageUnverified

Julien Robert committed 2026-04-21T23:44:24+02:00 Browse files
1e8c440 parent: 0c15e0d
modified internal/db/article.go +0 -21
@@ -355,27 +355,6 @@ func (db *DB) GetArticleByURL(ctx context.Context, url string) (*Article, error)
355355 return a, nil
356356 }
357357
358-func (db *DB) GetReadCount(ctx context.Context, userDID, feedURL string) (int, error) {
359- var count int
360- if feedURL != "" {
361- err := db.QueryRowContext(ctx, `
362- SELECT COUNT(*)
363- FROM articles a
364- JOIN read_state r ON r.user_did = ? AND r.article_id = a.id
365- WHERE a.feed_url = ? AND r.is_read = 1
366- `, userDID, feedURL).Scan(&count)
367- return count, err
368- }
369- err := db.QueryRowContext(ctx, `
370- SELECT COUNT(*)
371- FROM articles a
372- JOIN subscriptions s ON a.feed_url = s.feed_url AND s.user_did = ?
373- JOIN read_state r ON r.user_did = ? AND r.article_id = a.id
374- WHERE r.is_read = 1
375- `, userDID, userDID).Scan(&count)
376- return count, err
377-}
378-
379358 func (db *DB) CountNewArticles(ctx context.Context, userDID string, since time.Time) (int, error) {
380359 var count int
381360 err := db.QueryRowContext(ctx, `
@@ -355,27 +355,6 @@ func (db *DB) GetArticleByURL(ctx context.Context, url string) (*Article, error)
355 return a, nil355 return a, nil
356 }356 }
357 357
358-func (db *DB) GetReadCount(ctx context.Context, userDID, feedURL string) (int, error) {
359- var count int
360- if feedURL != "" {
361- err := db.QueryRowContext(ctx, `
362- SELECT COUNT(*)
363- FROM articles a
364- JOIN read_state r ON r.user_did = ? AND r.article_id = a.id
365- WHERE a.feed_url = ? AND r.is_read = 1
366- `, userDID, feedURL).Scan(&count)
367- return count, err
368- }
369- err := db.QueryRowContext(ctx, `
370- SELECT COUNT(*)
371- FROM articles a
372- JOIN subscriptions s ON a.feed_url = s.feed_url AND s.user_did = ?
373- JOIN read_state r ON r.user_did = ? AND r.article_id = a.id
374- WHERE r.is_read = 1
375- `, userDID, userDID).Scan(&count)
376- return count, err
377-}
378-
379 func (db *DB) CountNewArticles(ctx context.Context, userDID string, since time.Time) (int, error) {358 func (db *DB) CountNewArticles(ctx context.Context, userDID string, since time.Time) (int, error) {
380 var count int359 var count int
381 err := db.QueryRowContext(ctx, `360 err := db.QueryRowContext(ctx, `
modified internal/server/articles_handler.go +2 -2
@@ -39,8 +39,8 @@ func (s *Server) handleArticles(w http.ResponseWriter, r *http.Request) {
3939 page := pageFromRequest(r, 50)
4040
4141 if status == "" && searchQuery == "" {
42- readCount, _ := s.db.GetReadCount(r.Context(), user.DID, feedURL)
43- if readCount > 0 {
42+ unreadCount, _ := s.db.GetUnreadCount(r.Context(), user.DID, feedURL)
43+ if unreadCount > 0 {
4444 status = "unread"
4545 }
4646 }
@@ -39,8 +39,8 @@ func (s *Server) handleArticles(w http.ResponseWriter, r *http.Request) {
39 page := pageFromRequest(r, 50)39 page := pageFromRequest(r, 50)
40 40
41 if status == "" && searchQuery == "" {41 if status == "" && searchQuery == "" {
42- readCount, _ := s.db.GetReadCount(r.Context(), user.DID, feedURL)42+ unreadCount, _ := s.db.GetUnreadCount(r.Context(), user.DID, feedURL)
43- if readCount > 0 {43+ if unreadCount > 0 {
44 status = "unread"44 status = "unread"
45 }45 }
46 }46 }