add optional limit to listpkgs
order by id
This commit is contained in:
parent
1a09c1cdf9
commit
d248cc3132
@ -51,9 +51,10 @@ pub struct ListPackageModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[openapi(tag = "test")]
|
#[openapi(tag = "test")]
|
||||||
#[get("/packages/list")]
|
#[get("/packages/list?<limit>")]
|
||||||
pub async fn package_list(
|
pub async fn package_list(
|
||||||
db: &State<DatabaseConnection>,
|
db: &State<DatabaseConnection>,
|
||||||
|
limit: Option<u64>,
|
||||||
) -> Result<Json<Vec<ListPackageModel>>, NotFound<String>> {
|
) -> Result<Json<Vec<ListPackageModel>>, NotFound<String>> {
|
||||||
let db = db as &DatabaseConnection;
|
let db = db as &DatabaseConnection;
|
||||||
|
|
||||||
@ -67,6 +68,8 @@ pub async fn package_list(
|
|||||||
.column_as(packages::Column::LatestAurVersion, "latest_aur_version")
|
.column_as(packages::Column::LatestAurVersion, "latest_aur_version")
|
||||||
.column_as(versions::Column::Version, "latest_version")
|
.column_as(versions::Column::Version, "latest_version")
|
||||||
.column_as(packages::Column::LatestVersionId, "latest_version_id")
|
.column_as(packages::Column::LatestVersionId, "latest_version_id")
|
||||||
|
.order_by(packages::Column::Id, Order::Desc)
|
||||||
|
.limit(limit)
|
||||||
.into_model::<ListPackageModel>()
|
.into_model::<ListPackageModel>()
|
||||||
.all(db)
|
.all(db)
|
||||||
.await
|
.await
|
||||||
|
@ -70,7 +70,7 @@ async fn queue_package(
|
|||||||
new_build.status = Set(Some(0));
|
new_build.status = Set(Some(0));
|
||||||
new_build = new_build.save(&db).await.unwrap();
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user