Skip to content

feat(automations): add file count condition field#2163

Open
B4reMetal wants to merge 5 commits into
autobrr:developfrom
B4reMetal:feat/file_count_for_automations
Open

feat(automations): add file count condition field#2163
B4reMetal wants to merge 5 commits into
autobrr:developfrom
B4reMetal:feat/file_count_for_automations

Conversation

@B4reMetal

@B4reMetal B4reMetal commented Jul 21, 2026

Copy link
Copy Markdown

Summary

Adds a File Count condition field to the automations query builder — lets rules filter/sort torrents by how many files they contain

Summary by CodeRabbit

  • New Features

    • Added a File Count field to the automation query builder.
    • Use file count in conditions, sorting, previews, and automated rule execution.
    • Added translations for the new field across supported languages.
  • Documentation

    • Documented the File Count field and its behavior in automation conditions.
  • Bug Fixes

    • File Count rules now evaluate correctly using each torrent’s current file count.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2991df9a-6eed-478e-b33e-de8b06733371

📥 Commits

Reviewing files that changed from the base of the PR and between 4eaaab3 and ad439a0.

📒 Files selected for processing (18)
  • documentation/docs/features/automations.md
  • internal/models/automation.go
  • internal/services/automations/condition.go
  • internal/services/automations/evaluator.go
  • internal/services/automations/evaluator_test.go
  • internal/services/automations/file_count.go
  • internal/services/automations/processor.go
  • internal/services/automations/service.go
  • web/src/components/query-builder/constants.ts
  • web/src/i18n/locales/cs/automations.json
  • web/src/i18n/locales/de/automations.json
  • web/src/i18n/locales/en/automations.json
  • web/src/i18n/locales/fr/automations.json
  • web/src/i18n/locales/it/automations.json
  • web/src/i18n/locales/ko/automations.json
  • web/src/i18n/locales/uk/automations.json
  • web/src/i18n/locales/zh-CN/automations.json
  • web/src/types/automation.ts

Walkthrough

Added the FILE_COUNT automation field across backend models, evaluation, preview and live execution, query-builder UI, translations, and documentation. File counts are fetched from qBittorrent and keyed by torrent hash for conditions and sorting.

Changes

File Count Automation Support

Layer / File(s) Summary
Field contracts and UI exposure
internal/models/automation.go, internal/services/automations/condition.go, web/src/types/automation.ts, web/src/components/query-builder/constants.ts, web/src/i18n/locales/*/automations.json, documentation/docs/features/automations.md
Defines FILE_COUNT as a numeric condition field, adds it to the Files query-builder group, localizes its label, and documents its meaning.
File-count retrieval and context wiring
internal/services/automations/file_count.go, internal/services/automations/service.go
Fetches torrent file lists through GetTorrentFilesBatch, builds hash-to-count data, and populates preview or live evaluation context when needed.
Condition and sorting evaluation
internal/services/automations/evaluator.go, internal/services/automations/processor.go, internal/services/automations/evaluator_test.go
Evaluates FILE_COUNT conditions and sorting values by torrent hash, with tests for comparisons and missing context or entries.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

  • autobrr/qui#1061: Adds a filesystem-derived automation condition through similar evaluator and service context paths.
  • autobrr/qui#1677: Extends numeric automation fields across shared validation and query-builder paths.
  • autobrr/qui#1830: Adds another numeric condition field through the automation evaluation flow.

Suggested labels: enhancement, automations

Suggested reviewers: s0up4200, nitrobass24

Sequence Diagram(s)

sequenceDiagram
  participant AutomationService
  participant SyncManager
  participant EvalContext
  participant Evaluator
  AutomationService->>SyncManager: Fetch torrent files in batch
  SyncManager-->>AutomationService: Return file lists
  AutomationService->>EvalContext: Store FileCountByHash
  Evaluator->>EvalContext: Read count by torrent hash
  Evaluator-->>AutomationService: Compare FILE_COUNT condition
Loading

Poem

A rabbit counts files in a torrent so neat,
Then hops through each rule with a numerical beat.
From qBittorrent’s list to the query-builder view,
“File Count!” it whispers, localized anew.
Conditions now sort as the carrots grow tall. 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a file count condition field for automations.
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.
✨ 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.

@B4reMetal

B4reMetal commented Jul 21, 2026

Copy link
Copy Markdown
Author

Noticed that #1190 is related.

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