labrinth icon indicating copy to clipboard operation
labrinth copied to clipboard

`version_type` filtering for `version_file`

Open 4JX opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe. Primarily meant for /version_file/{hash}/update but there may be other similar routes.

The route currently returns whatever the latest file for the mod regardless of its release type. However, it is not always desirable to ignore it as alpha/beta releases may be unstable and cause issues when used.

Describe the solution you'd like I would like the behaviour to be changed so that instead of returning only the latest version, it will behave similarly to a filtered version search to project/{project_id}/version which uses an array of matching entries for the response.

Describe alternatives you've considered Doing two calls to first get the project_id and then using that in project/{project_id}/version, filtering by the release type locally.

4JX avatar Feb 17 '22 13:02 4JX

Oops, commented on the wrong issue

Geometrically avatar Feb 17 '22 23:02 Geometrically

I would suggest a new field for filtering like the loaders or game_versions. A request body would if implemented look like this:

{
   "loaders":[
      "fabric"
   ],
   "game_versions":[
      "1.18.2"
   ],
   "version_type":[
      "release"
   ]
}

For me getting the project id and then filtering the versions at the client manually is not an option because some mods don't follow SemVer which makes filtering for the latest version erroneous.

DeathsGun avatar Apr 27 '22 06:04 DeathsGun

Did a test for this in https://github.com/4JX/labrinth/commit/c2f34edd987d2c2f5a6b8609386a8ef2016e132c and it seems to work, thought the efficiency of filtering after getting the initial "get the versions" query is probably not the best.

The better option would probably be to make the get_project_versions function take a Vec<VersionType>/Option<Vec<VersionType>>, as an argument, but I don't know if changing the function's signature would be preferred when this type of filtering is not used anywhere else.

4JX avatar May 27 '22 15:05 4JX

Fixed in staging commit (will be on prod soon)

Geometrically avatar Jul 12 '23 02:07 Geometrically