Skip to content

Endpoint to get a list of torrents does not return all torrents #84

@josecelano

Description

@josecelano

Endpoint: http://0.0.0.0:3000/torrents?page_size=20&page=0&sort=UploadedDesc&categories=&search=

Expected response:

{
  "data": {
    "total": 2,
    "results": [
      {
        "torrent_id": 1,
        "uploader": "user01",
        "info_hash": "9e0217d0fa71c87332cd8bf9dbeabcb2c2cf3c4d",
        "title": "A Mandelbrot Set 2048x2048px picture",
        "description": "A beautiful Mandelbrot Set picture in black and white. \n - Hybrid torrent V1 and V2. \n - Single-file torrent. \n - Public. \n - More than one tracker URL. \n ",
        "category_id": 10,
        "date_uploaded": "2022-11-04 07:19:18",
        "file_size": 9219566,
        "seeders": 0,
        "leechers": 0
      },
      {
        "torrent_id": 2,
        "uploader": "user01",
        "info_hash": "0902d375f18ec020f0cc68ed4810023032ba81cb",
        "title": "Two Mandelbrot Set 2048x2048px pictures",
        "description": "Two beautiful Mandelbrot Set pictures in black and white. \n - Hybrid torrent V1 and V2. \n - Multiple-files torrent. \n - Private. \n - Only one tracker URL. \n ",
        "category_id": 10,
        "date_uploaded": "2022-11-04 07:19:18",
        "file_size": 9219566,
        "seeders": 0,
        "leechers": 0
      }
    ]
  }
}

Actual response:

{
  "data": {
    "total": 1,
    "results": [
      {
        "torrent_id": 1,
        "uploader": "user01",
        "info_hash": "9e0217d0fa71c87332cd8bf9dbeabcb2c2cf3c4d",
        "title": "A Mandelbrot Set 2048x2048px picture",
        "description": "A beautiful Mandelbrot Set picture in black and white. \n - Hybrid torrent V1 and V2. \n - Single-file torrent. \n - Public. \n - More than one tracker URL. \n ",
        "category_id": 10,
        "date_uploaded": "2022-11-04 07:19:18",
        "file_size": 9219566,
        "seeders": 0,
        "leechers": 0
      }
    ]
  }
}

How to reproduce

  1. Run this backend test: cargo test upgrades_data_from_version_v1_0_0_to_v2_0_0 -- --nocapture. It's still only available on PR Command to migrate DB data from v1.0.0 to v2.0.0 #77 77. That will produce a tests DB in thetests/upgrades/from_v1_0_0_to_v2_0_0/output dir.
  2. Run the tracker
  3. Run the backend using the previously generated database.
  4. Run the frontend
  5. Load this URL: http://localhost:8080/torrents/trending. You will see only one torrent A Mandelbrot Set 2048x2048px picture.
  6. Click on the torrent name to go to the torrent details page and back to the previous list page. You will now see two torrents.
  7. If you go to the DB and delete all records in the torrust_toprrent_tracker_stats, you will see only one result again.

Conclusion

There must be a problem with the SQL sentence. Maybe there is an inner join that uses that table.
The torrent that does not appear is private if that helps find the issue.

Attachments

The bug. THe list with only one torrent.

image

The torrent detail page.

image

The correct list page with two torrents.

image

The stats table with one record. ONce you have that record, the list page is right.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIncorrect Behavior

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions