Skip to content

feat: add --before and --since date flags to article list command#21

Open
map9959 wants to merge 1 commit intoJulienTant:mainfrom
map9959:date-filters-for-articles
Open

feat: add --before and --since date flags to article list command#21
map9959 wants to merge 1 commit intoJulienTant:mainfrom
map9959:date-filters-for-articles

Conversation

@map9959
Copy link
Copy Markdown

@map9959 map9959 commented Apr 23, 2026

Summary

Adds --before and --since date flags to the article list command that accept YYYY-MM-DD formatted dates. If either of these are specified, articles without dates are filtered out completely, and articles are filtered by date.

--before is exclusive, functioning as <, and --since is inclusive, functioning as >=.

Test plan

Verified with golangci-lint and gotestsum, and manually verified on the Slashdot feed.

  • golangci-lint run passes
  • gotestsum -- ./... passes
  • Manually verified (if applicable)

AI Disclaimer

I made this with Opencode. It was an easy oneshot and would improve my life. Thanks for checking it out.

Summary by CodeRabbit

  • New Features
    • Articles command now supports --since and --before flags for filtering by publication date
    • Date format required: YYYY-MM-DD
    • --since filters inclusively from the specified date; --before filters exclusively before the date
    • Combined range filtering is supported
    • Articles without publication dates are excluded when date filters are applied

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@map9959 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 47 minutes and 10 seconds before requesting another review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1ba0e516-3eba-421e-bf22-95ef6d976d24

📥 Commits

Reviewing files that changed from the base of the PR and between d444a62 and f96107e.

📒 Files selected for processing (7)
  • README.md
  • internal/cli/commands.go
  • internal/controller/controller.go
  • internal/controller/controller_test.go
  • internal/scanner/scanner_test.go
  • internal/storage/database.go
  • internal/storage/database_test.go
📝 Walkthrough

Walkthrough

This PR introduces date filtering for articles via new CLI flags. The --since and --before options enable filtering by publication date in YYYY-MM-DD format. Changes propagate through controller and storage layers, updating function signatures to accept optional time parameters for query filtering.

Changes

Cohort / File(s) Summary
CLI Interface
README.md, internal/cli/commands.go
Documentation and implementation of --since and --before flags for the articles subcommand, including date parsing into *time.Time with error handling, and forwarding to controller.
Controller Layer
internal/controller/controller.go, internal/controller/controller_test.go
Updated GetArticles signature to accept optional since and before time filters; forwarded to database layer; test call sites updated with new parameters.
Storage Layer
internal/storage/database.go, internal/storage/database_test.go
Extended ListArticles signature with since and before parameters; conditional SQL filtering on published_date using RFC3339Nano layout; comprehensive date-filtering test added.
Scanner Tests
internal/scanner/scanner_test.go
Updated db.ListArticles call sites to match new function signature with nil arguments for date filters.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Hop through the archives with newfound grace,
--since and --before mark time and place,
From RFC3339 to SQL's embrace,
Articles bloom in their temporal space! 🌱📅

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately and concisely summarizes the main change: adding --before and --since date flags to the article list command.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The pull request description covers both required sections with specific details about functionality, testing approach, and verification status.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between e8d8508 and d444a62.

📒 Files selected for processing (7)
  • README.md
  • internal/cli/commands.go
  • internal/controller/controller.go
  • internal/controller/controller_test.go
  • internal/scanner/scanner_test.go
  • internal/storage/database.go
  • internal/storage/database_test.go

Comment thread internal/storage/database.go
Comment thread README.md Outdated
chore: update readme to include info about --before and --since

chore: clarify dates in README
@map9959 map9959 force-pushed the date-filters-for-articles branch from d444a62 to f96107e Compare April 23, 2026 04:47
@map9959 map9959 mentioned this pull request Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant