Skip to content

Commit

Permalink
Merge pull request #279 from strideynet/kev-hide-old-imported-posts
Browse files Browse the repository at this point in the history
Hide posts with created_at older than 7 days
  • Loading branch information
KevSlashNull authored Nov 18, 2024
2 parents 094ee0e + 8015d63 commit 9e999cf
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions feed/feed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func TestGenerator(t *testing.T) {
if opts.IndexedAt.IsZero() {
opts.IndexedAt = now
}
if opts.CreatedAt.IsZero() {
opts.CreatedAt = 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.

1 change: 1 addition & 0 deletions store/migrations/000024_add_post_created_at_index.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DROP INDEX candidate_posts_created_at_idx;
1 change: 1 addition & 0 deletions store/migrations/000024_add_post_created_at_index.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CREATE INDEX candidate_posts_created_at_idx ON public.candidate_posts (created_at);
2 changes: 2 additions & 0 deletions store/queries/candidate_posts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,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'
AND cp.created_at > NOW() - INTERVAL '7 day'
ORDER BY
cp.indexed_at DESC
LIMIT sqlc.arg(_limit);
Expand Down Expand Up @@ -156,6 +157,7 @@ WHERE
< ROW((sqlc.arg(after_score))::REAL, (sqlc.arg(after_uri))::TEXT)
)
AND cp.indexed_at > NOW() - INTERVAL '7 day'
AND cp.created_at > NOW() - INTERVAL '7 day'
ORDER BY
ph.score DESC, ph.uri DESC
LIMIT sqlc.arg(_limit);

0 comments on commit 9e999cf

Please sign in to comment.