Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider refactoring primitive type TorrentsMetrics #1243

Closed
josecelano opened this issue Feb 5, 2025 · 1 comment · Fixed by #1361
Closed

Consider refactoring primitive type TorrentsMetrics #1243

josecelano opened this issue Feb 5, 2025 · 1 comment · Fixed by #1361
Assignees
Labels
Code Cleanup / Refactoring Tidying and Making Neat

Comments

@josecelano
Copy link
Member

The type TorrentsMetrics includes the same info as the SwarmMetadata:

torrust_tracker_primitives::swarm_metadata
pub struct SwarmMetadata {
    pub downloaded: u32,
    pub complete: u32,
    pub incomplete: u32,
}

torrust_tracker_primitives::torrent_metrics
pub struct TorrentsMetrics {
    pub complete: u64,
    pub downloaded: u64,
    pub incomplete: u64,
    pub torrents: u64,
}

We could refactor it to:

torrust_tracker_primitives::torrent_metrics
pub struct TorrentsMetrics {
    pub swarm_metadata: SwarmMetadata,
    pub torrents: u64,
}

SwarmMetadata would not change.

What do you think @da2ce7?

IMPORTANT: do not start this refactor until I finish the Overhaul core::Tracker epic.

@josecelano josecelano added the Code Cleanup / Refactoring Tidying and Making Neat label Feb 5, 2025
@josecelano josecelano self-assigned this Mar 6, 2025
@josecelano
Copy link
Member Author

I've just realized they are different because TorrentsMetrics are for all torrents while SwarmMetadata is only for one torrent. I will only make minor changes to make than difference clearer.

josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 7, 2025
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 7, 2025
…SwarmMetadata)

To avoid confusion with `SwarmMetadata`

- `SwarmMetadata`: metrics for one torrent.
- `AggregateSwarmMetadata`: metrics for all torrents.
@josecelano josecelano linked a pull request Mar 7, 2025 that will close this issue
josecelano added a commit to josecelano/torrust-tracker that referenced this issue Mar 7, 2025
…SwarmMetadata)

To avoid confusion with `SwarmMetadata`

- `SwarmMetadata`: metrics for one torrent.
- `AggregateSwarmMetadata`: metrics for all torrents.
josecelano added a commit that referenced this issue Mar 7, 2025
…adata`

144a338 refactor: [#1243] move and rename struct and fields (AggregateSwarmMetadata) (Jose Celano)
2020162 chore: [#1243] minor changes in comments and format (Jose Celano)

Pull request description:

  `TorrentsMetrics` has been refactored and moved to the `swarm_metadata` module.

  From (`packages/primitives/src/torrent_metrics.rs`):

  ```rust
  pub struct TorrentsMetrics {
      pub complete: u64,
      pub downloaded: u64,
      pub incomplete: u64,
      pub torrents: u64,
  }
  ```

  To (`packages/primitives/src/swarm_metadata.rs`):

  ```rust
  pub struct AggregateSwarmMetadata {
      pub total_complete: u64,
      pub total_downloaded: u64,
      pub total_incomplete: u64,
      pub total_torrents: u64,
  }
  ```

ACKs for top commit:
  josecelano:
    ACK 144a338

Tree-SHA512: 2c1c9fbbf602921a94ce4cd51ebe332a3b4d53680abecc6899ff8a79fafe07ae055da678e205911b40c0648b8c473e9140272e384be71f85d96a1c0b74c3ce3c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Code Cleanup / Refactoring Tidying and Making Neat
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant