Skip to content

refactor(primitives): rename NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash#1972

Merged
josecelano merged 2 commits into
torrust:developfrom
josecelano:1964-rename-number-of-downloads-btree-map
Jul 13, 2026
Merged

refactor(primitives): rename NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash#1972
josecelano merged 2 commits into
torrust:developfrom
josecelano:1964-rename-number-of-downloads-btree-map

Conversation

@josecelano

Copy link
Copy Markdown
Member

What

Renamed the type alias NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash across the entire workspace (23 source files + docs).

Why

The old name NumberOfDownloadsBTreeMap leaks the implementation detail (BTreeMap). The new name expresses what the type represents ("downloads per info-hash") rather than how it's stored, matching the convention of its sibling NumberOfDownloads.

Closes #1964

How

  • Changed the definition in packages/primitives/src/lib.rs
  • Updated all imports and usages in tracker-core, swarm-coordination-registry, torrent-repository-benchmarking, and their tests
  • Updated 4 documentation files referencing the old name
  • Verified: cargo build --workspace succeeds, all unit tests pass, linter all passes (clippy failure is pre-existing in http_health_check, unrelated)

Verification

  • Build: cargo build --workspace — success
  • Tests: cargo test --workspace --all-targets --all-features — 262 tests pass, 0 failures
  • Linting: markdown, yaml, toml, cspell, rustfmt, shellcheck all pass
  • grep: No .rs or .md files contain the old name (except the issue spec itself)
  • Pre-commit checks: all pass

Copilot AI review requested due to automatic review settings July 13, 2026 08:52
…nloadsPerInfoHash

Rename the type alias to express intent ('downloads per info-hash') rather than internal implementation (BTreeMap).

Updated across all packages: primitives, tracker-core, swarm-coordination-registry, torrent-repository-benchmarking, and related documentation.

- 24 files modified
- No code references to the old name remain (verified via grep)
- All tests pass, linters pass (pre-existing unrelated clippy warning in http_health_check.rs)
@josecelano
josecelano force-pushed the 1964-rename-number-of-downloads-btree-map branch from be065d6 to e0fbe78 Compare July 13, 2026 08:56
@josecelano josecelano self-assigned this Jul 13, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR performs a workspace-wide refactor to rename the primitives type alias NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash, improving API clarity by removing the leaked BTreeMap implementation detail while keeping the underlying type unchanged.

Changes:

  • Renamed the type alias in torrust-tracker-primitives and updated all downstream imports/usages.
  • Updated database trait/driver return types to use the new alias name consistently.
  • Refreshed documentation references to the renamed alias.

Reviewed changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/tracker-core/src/torrent/repository/in_memory.rs Updates import and import_persistent signature to the new alias.
packages/tracker-core/src/statistics/persisted/downloads.rs Updates repository return type and test expectations to the new alias.
packages/tracker-core/src/databases/traits/torrent_metrics.rs Renames the persistence trait return type to the new alias.
packages/tracker-core/src/databases/driver/sqlite/torrent_metrics_store.rs Updates SQLite driver trait impl signature to the new alias.
packages/tracker-core/src/databases/driver/postgres/torrent_metrics_store.rs Updates Postgres driver trait impl signature to the new alias.
packages/tracker-core/src/databases/driver/mysql/torrent_metrics_store.rs Updates MySQL driver trait impl signature to the new alias.
packages/torrent-repository-benchmarking/tests/repository/mod.rs Updates fixtures and test parameters to use the new alias type.
packages/torrent-repository-benchmarking/tests/common/repo.rs Updates helper repository wrapper API to accept the new alias.
packages/torrent-repository-benchmarking/src/repository/skip_map_mutex_std.rs Renames import_persistent parameter type to the new alias in implementations.
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio.rs Renames async import_persistent parameter type to the new alias.
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_tokio.rs Renames async import_persistent parameter type to the new alias.
packages/torrent-repository-benchmarking/src/repository/rw_lock_tokio_mutex_std.rs Renames async import_persistent parameter type to the new alias.
packages/torrent-repository-benchmarking/src/repository/rw_lock_std.rs Renames import_persistent parameter type to the new alias.
packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_tokio.rs Renames import_persistent parameter type to the new alias.
packages/torrent-repository-benchmarking/src/repository/rw_lock_std_mutex_std.rs Renames import_persistent parameter type to the new alias.
packages/torrent-repository-benchmarking/src/repository/mod.rs Updates repository traits’ import_persistent signatures to the new alias.
packages/torrent-repository-benchmarking/src/repository/dash_map_mutex_std.rs Renames import_persistent parameter type to the new alias.
packages/swarm-coordination-registry/src/swarm/registry.rs Updates registry API and tests to accept the new alias.
packages/primitives/src/lib.rs Renames the exported type alias definition.
docs/issues/open/1964-rename-number-of-downloads-btree-map-type-alias.md Marks tasks/verification as DONE and updates evidence sections.
docs/issues/open/1669-overhaul-packages/workspace-coupling-report-proposed-merge.md Updates the referenced primitives type name.
docs/issues/open/1669-overhaul-packages/workspace-coupling-report-2026-06-10.md Updates the referenced primitives type name in multiple places.
docs/issues/open/1669-overhaul-packages/workspace-coupling-report-2026-05-19.md Updates the referenced primitives type name in multiple places.
docs/issues/closed/1713-1525-04-split-persistence-traits.md Updates the example trait signatures to the new alias.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/issues/open/1964-rename-number-of-downloads-btree-map-type-alias.md Outdated
The AC1 evidence now explicitly states that no `.rs` files contain the
old type name, and the only `.md` file with it is the spec itself
(intentionally). This addresses a Copilot review comment on PR torrust#1972.

Also sets the `related-pr` field and adds a progress log entry.
@josecelano

Copy link
Copy Markdown
Member Author

ACK 9fd2861

@josecelano
josecelano merged commit fd88bb6 into torrust:develop Jul 13, 2026
25 checks passed
@josecelano
josecelano deleted the 1964-rename-number-of-downloads-btree-map branch July 13, 2026 10:23
josecelano added a commit that referenced this pull request Jul 15, 2026
…ssues/open to docs/issues/closed

174904d chore(ci): point to ADR instead of closed issue spec in deployment-packages.yaml (Jose Celano)
2e2178f docs(skill): document branch-already-exists edge case in cleanup-completed-issues skill (Jose Celano)
1bfd306 chore(issues): archive closed issue specs #1447, #1459, #1505, #1926, #1938, #1944, #1959, #1964, #1965, #1969 to docs/issues/closed (Jose Celano)

Pull request description:

  Archives the following 10 issue specs that are closed on GitHub, moving them from `docs/issues/open/` to `docs/issues/closed/`:

  | Issue | Title | PR |
  |-------|-------|-----|
  | #1447 | Change logging threshold for connection ID error to WARNING | #1975 |
  | #1459 | Docker Security Overhaul | #1958 |
  | #1505 | Optimize peer IP list from swarm (implementation rejected) | #1949 |
  | #1926 | Define package versioning strategy | #1961 |
  | #1938 | REST API Contract-First Migration EPIC | #1960 (SI-1→5) |
  | #1944 | SI-6: Align REST API client | #1968 |
  | #1959 | SI-7: Review tests, align v1 namespace | #1963 |
  | #1964 | Rename number-of-downloads BTreeMap type alias | #1972 |
  | #1965 | SI-34: Consolidate duplicate HTTP types | #1974 |
  | #1969 | SI-8: Eliminate unwraps from REST API client | #1973 |

  ### Changes Made

  - All 10 specs verified `CLOSED` on GitHub with merged PRs
  - Files/directories moved via `git mv` to `docs/issues/closed/`
  - Frontmatter updated: `status: done`, `spec-path` → closed path, `last-updated-utc: 2026-07-15`
  - Workflow checkpoints updated and progress log entries added
  - Supplementary files in multi-file directories updated with new paths
  - Parent EPIC specs (#1669, #1938) updated: subissue status, spec paths, and table references
  - Fixed stale references in `.github/workflows/deployment-packages.yaml`, `docs/adrs/`, and `docs/issues/closed/` files
  - Pre-commit and pre-push hooks passed (linter, tests, doc-tests, nightly checks)

ACKs for top commit:
  josecelano:
    ACK 174904d

Tree-SHA512: c7e38354bb5898fc5125a0b68fd61a02ca273689593638eb3b955b9176038ef82c40fc98b0a2f722eb18d8d429d2f2dbb6f205eee3061211ab9906c5be46942b
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.

Rename NumberOfDownloadsBTreeMap to NumberOfDownloadsPerInfoHash

2 participants