Skip to content

Commit

Permalink
Merge pull request #256 from strideynet/kev-limit-posts-to-last-7-days
Browse files Browse the repository at this point in the history
Limit posts in feeds to last 7 days
  • Loading branch information
strideynet authored Oct 15, 2024
2 parents fb1c66e + 681ffac commit 5aec938
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
12 changes: 12 additions & 0 deletions feed/feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,22 @@ func TestGenerator(t *testing.T) {
nsfwVideoPost := indigoTest.RandFakeAtUri("app.bsky.feed.post", "nsfw-video")
nsfwArtVideoPost := indigoTest.RandFakeAtUri("app.bsky.feed.post", "nsfw-art-video")
artVideoPost := indigoTest.RandFakeAtUri("app.bsky.feed.post", "art-video")
oldPost := indigoTest.RandFakeAtUri("app.bsky.feed.post", "old-post")

now := time.Now()

for _, opts := range []store.CreatePostOpts{
{
URI: fursuitPost,
Hashtags: []string{"fursuit"},
HasMedia: true,
},
{
URI: oldPost,
ActorDID: furry.DID(),
IndexedAt: now.Add(-time.Hour * 24 * 8),
HasMedia: true,
},
{
URI: murrsuitPost,
Hashtags: []string{"fursuit", "murrsuit"},
Expand Down Expand Up @@ -118,6 +127,9 @@ func TestGenerator(t *testing.T) {
if opts.Hashtags == nil {
opts.Hashtags = []string{}
}
if opts.IndexedAt.IsZero() {
opts.IndexedAt = now
}
require.NoError(t, harness.Store.CreatePost(ctx, opts))
}

Expand Down
2 changes: 2 additions & 0 deletions store/gen/candidate_posts.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions store/queries/candidate_posts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ WHERE
)
-- Remove posts newer than the cursor timestamp
AND (cp.indexed_at < sqlc.arg(cursor_timestamp))
AND cp.indexed_at > NOW() - INTERVAL '7 day'
ORDER BY
cp.indexed_at DESC
LIMIT sqlc.arg(_limit);
Expand Down Expand Up @@ -136,6 +137,7 @@ WHERE
ROW(ph.score, ph.uri)
< ROW((sqlc.arg(after_score))::REAL, (sqlc.arg(after_uri))::TEXT)
)
AND cp.indexed_at > NOW() - INTERVAL '7 day'
ORDER BY
ph.score DESC, ph.uri DESC
LIMIT sqlc.arg(_limit);

0 comments on commit 5aec938

Please sign in to comment.