add optional limit to listpkgs

order by id
This commit is contained in:
lukas-heiligenbrunner 2024-01-15 16:28:56 +01:00
parent 1a09c1cdf9
commit d248cc3132
2 changed files with 5 additions and 2 deletions

View File

@ -51,9 +51,10 @@ pub struct ListPackageModel {
}
#[openapi(tag = "test")]
#[get("/packages/list")]
#[get("/packages/list?<limit>")]
pub async fn package_list(
db: &State<DatabaseConnection>,
limit: Option<u64>,
) -> Result<Json<Vec<ListPackageModel>>, NotFound<String>> {
let db = db as &DatabaseConnection;
@ -67,6 +68,8 @@ pub async fn package_list(
.column_as(packages::Column::LatestAurVersion, "latest_aur_version")
.column_as(versions::Column::Version, "latest_version")
.column_as(packages::Column::LatestVersionId, "latest_version_id")
.order_by(packages::Column::Id, Order::Desc)
.limit(limit)
.into_model::<ListPackageModel>()
.all(db)
.await

View File

@ -70,7 +70,7 @@ async fn queue_package(
new_build.status = Set(Some(0));
new_build = new_build.save(&db).await.unwrap();
build_package(new_build, db, version_model, version, name, url).await;
let _ = build_package(new_build, db, version_model, version, name, url).await;
});
Ok(())
}