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

Get torrents endpoint max number of results is too small #797

Closed
mario-nt opened this issue Jan 22, 2025 · 0 comments · Fixed by #798
Closed

Get torrents endpoint max number of results is too small #797

mario-nt opened this issue Jan 22, 2025 · 0 comments · Fixed by #798
Assignees
Labels
Bug Incorrect Behavior

Comments

@mario-nt
Copy link
Contributor

Description

By default, the torrent list/table components of the GUI has a default page size (number of results that are going to be displayed in each page) of 50 elements, but only 30 of them are shown:

Image

This is because the API configuration has a limit of a maximum of 30 elements per request:

/// Core configuration for the API
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Api {
    /// The default page size for torrent lists.
    #[serde(default = "Api::default_default_torrent_page_size")]
    pub default_torrent_page_size: u8,

    /// The maximum page size for torrent lists.
    #[serde(default = "Api::default_max_torrent_page_size")]
    pub max_torrent_page_size: u8,

    /// The default page size for user profile lists.
    #[serde(default = "Api::default_user_profile_page_size")]
    pub default_user_profile_page_size: u8,

    /// The maximum page size for user profile lists.
    #[serde(default = "Api::default_max_user_profile_page_size")]
    pub max_user_profile_page_size: u8,
}

impl Default for Api {
    fn default() -> Self {
        Self {
            default_torrent_page_size: Api::default_default_torrent_page_size(),
            max_torrent_page_size: Api::default_max_torrent_page_size(),
            default_user_profile_page_size: Api::default_user_profile_page_size(),
            max_user_profile_page_size: Api::default_max_user_profile_page_size(),
        }
    }
}

impl Api {
    fn default_default_torrent_page_size() -> u8 {
        10
    }

    fn default_max_torrent_page_size() -> u8 {
        30
    }

    fn default_user_profile_page_size() -> u8 {
        10
    }

    fn default_max_user_profile_page_size() -> u8 {
        100
    }
}

That creates an inconsistent number of elements being displayed between the pagination component and the torrent list/torrents table components, resulting in an incorrect number of torrents shown to the user when setting a page size of 50 or 100 results.

This does not affect the page size value of 20.

How to reproduce

  1. Navigate to the torrents page (/torrents) (At least 31 torrents has to be uploaded)
  2. Count the torrents (the search function of the browser can be used for this if all torrents share some words in common)
  3. You should see the pagination component showing 1 to 31 of 31 results but only 30 torrents are shown
  4. Change the page size to 100 and the same error occurs
@mario-nt mario-nt self-assigned this Jan 22, 2025
@mario-nt mario-nt added the Bug Incorrect Behavior label Jan 22, 2025
mario-nt added a commit to mario-nt/torrust-index that referenced this issue Jan 22, 2025
mario-nt added a commit to mario-nt/torrust-index that referenced this issue Jan 22, 2025
mario-nt added a commit to mario-nt/torrust-index that referenced this issue Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Incorrect Behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant