Unread notifications count should be specific to a single user
This commit is contained in:
parent
9c7174a84a
commit
72b547f6aa
@ -116,9 +116,9 @@ func (p Profile) CheckNotificationScrapesNeeded(trove TweetTrove) []Notification
|
|||||||
return ret
|
return ret
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p Profile) GetUnreadNotificationsCount(since_sort_index int64) int {
|
func (p Profile) GetUnreadNotificationsCount(u_id UserID, since_sort_index int64) int {
|
||||||
var ret int
|
var ret int
|
||||||
err := p.DB.Get(&ret, `select count(*) from notifications where sort_index > ?`, since_sort_index)
|
err := p.DB.Get(&ret, `select count(*) from notifications where sort_index > ? and user_id = ?`, since_sort_index, u_id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
|
||||||
"gitlab.com/offline-twitter/twitter_offline_engine/pkg/persistence"
|
"gitlab.com/offline-twitter/twitter_offline_engine/pkg/persistence"
|
||||||
|
. "gitlab.com/offline-twitter/twitter_offline_engine/pkg/scraper"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSaveAndLoadNotification(t *testing.T) {
|
func TestSaveAndLoadNotification(t *testing.T) {
|
||||||
@ -32,6 +33,6 @@ func TestGetUnreadNotificationsCount(t *testing.T) {
|
|||||||
profile, err := persistence.LoadProfile("../../sample_data/profile")
|
profile, err := persistence.LoadProfile("../../sample_data/profile")
|
||||||
require.NoError(err)
|
require.NoError(err)
|
||||||
|
|
||||||
unread_notifs_count := profile.GetUnreadNotificationsCount(1724372973735)
|
unread_notifs_count := profile.GetUnreadNotificationsCount(UserID(1488963321701171204), 1724372973735)
|
||||||
assert.Equal(2, unread_notifs_count)
|
assert.Equal(2, unread_notifs_count)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user