Currently, a big query is ran to find packages that match some filters and a sort order. Then for each package, two queries are executed to find the screenshot and release.
This means there are 2*n + 1 queries which run in sequence, which results in a 10 second page load time.
Tables
Package:
id
PackageRelease:
id
package_id
min_rel
max_rel
PackageScreenshot:
id
package_id
approved
MinetestRelease
id
/api/packages/
In summary, the algorithm should be this:
For each package
Allow filtering and ordering package based on column values.
Filter package based on available releases (PackageRelease.min_rel>=version and PackageRelease.max_rel<=version).
Get the most recent release. This may be filtered to be the most recent in the bounds (PackageRelease.min_rel>=version and PackageRelease.max_rel<=version).
Get the most recent approved screenshot PackageScreenshot.approved = true.
The REST result looks a bit like this:
[
{
"author": "Jeija",
"name": "mesecons",
"release": 1771,
"short_description": "Adds digital circuitry, including wires, buttons, lights, and even programmable controllers.",
"thumbnail": "https://content.minetest.net/thumbnails/1/mwaTPqpj7e.png",
"title": "Mesecons",
"type": "mod"
}
]
Currently, a big query is ran to find packages that match some filters and a sort order. Then for each package, two queries are executed to find the screenshot and release.
This means there are
2*n + 1
queries which run in sequence, which results in a 10 second page load time.Tables
/api/packages/
In summary, the algorithm should be this:
PackageRelease.min_rel>=version
andPackageRelease.max_rel<=version
).PackageRelease.min_rel>=version
andPackageRelease.max_rel<=version
).PackageScreenshot.approved = true
.The REST result looks a bit like this: