feat: add --before and --since date flags to article list command#21
feat: add --before and --since date flags to article list command#21map9959 wants to merge 1 commit intoJulienTant:mainfrom
Conversation
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 47 minutes and 10 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR introduces date filtering for articles via new CLI flags. The Changes
Sequence DiagramsequenceDiagram
participant User as User/CLI
participant CLI as CLI Handler
participant Controller as Controller
participant Database as Database
User->>CLI: articles --since YYYY-MM-DD --before YYYY-MM-DD
CLI->>CLI: parseDateFilter() for each flag
CLI->>Controller: GetArticles(ctx, db, showAll, blogName, category, since, before)
Controller->>Database: ListArticles(ctx, unreadOnly, blogID, category, since, before)
Database->>Database: Build SQL query with date filters<br/>if since != nil: WHERE published_date >= since<br/>if before != nil: WHERE published_date < before
Database-->>Controller: []Article (filtered by date)
Controller-->>CLI: []Article
CLI-->>User: Filtered articles
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@internal/storage/database.go`:
- Around line 379-384: The date filters are formatted with a full timestamp
layout and compared lexically, causing misclassification; change the formatting
for the since and before time values used in the sq.GtOrEq{"published_date":
...} and sq.Lt{"published_date": ...} queries to a date-only layout
("2006-01-02") so comparisons use YYYY-MM-DD strings (e.g., replace uses of
sqliteTimeLayout / RFC3339Nano with a date-only format or a new sqliteDateLayout
constant) ensuring the CLI's parseDateFilter semantics (midnight UTC) match
database string comparisons for published_date.
In `@README.md`:
- Line 84: The example using the flags --since and --before is ambiguous about
inclusivity; update the README line showing "blogwatcher-cli articles --since
2024-01-01 --before 2024-01-15" to explicitly state that the range is
end-exclusive (i.e., includes 2024-01-01 up to but not including 2024-01-15) by
adding a short clarifying phrase after the example referencing the --since and
--before flags and that --before excludes the given end date.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a94c3bfc-69b2-4ee1-8c99-1fd5f2fe2a0f
📒 Files selected for processing (7)
README.mdinternal/cli/commands.gointernal/controller/controller.gointernal/controller/controller_test.gointernal/scanner/scanner_test.gointernal/storage/database.gointernal/storage/database_test.go
chore: update readme to include info about --before and --since chore: clarify dates in README
d444a62 to
f96107e
Compare
Summary
Adds
--beforeand--sincedate flags to the article list command that acceptYYYY-MM-DDformatted dates. If either of these are specified, articles without dates are filtered out completely, and articles are filtered by date.--beforeis exclusive, functioning as<, and--sinceis inclusive, functioning as>=.Test plan
Verified with
golangci-lintandgotestsum, and manually verified on the Slashdot feed.golangci-lint runpassesgotestsum -- ./...passesAI Disclaimer
I made this with Opencode. It was an easy oneshot and would improve my life. Thanks for checking it out.
Summary by CodeRabbit
--sinceand--beforeflags for filtering by publication date--sincefilters inclusively from the specified date;--beforefilters exclusively before the date