mirror of
https://github.com/danbulant/Portfolio
synced 2026-07-06 19:40:49 +00:00
refactor: struct name
This commit is contained in:
parent
d8a269edd3
commit
139248dc4c
1 changed files with 3 additions and 3 deletions
|
|
@ -8,7 +8,7 @@ use serde::Serialize;
|
||||||
pub const PAGE_SIZE: u64 = 20;
|
pub const PAGE_SIZE: u64 = 20;
|
||||||
|
|
||||||
#[derive(FromQueryResult, Serialize)]
|
#[derive(FromQueryResult, Serialize)]
|
||||||
pub struct ApplicationResult {
|
pub struct CandidateParentResult {
|
||||||
pub application: i32,
|
pub application: i32,
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub surname: Option<String>,
|
pub surname: Option<String>,
|
||||||
|
|
@ -30,7 +30,7 @@ impl Query {
|
||||||
pub async fn list_candidates(
|
pub async fn list_candidates(
|
||||||
db: &DbConn,
|
db: &DbConn,
|
||||||
field_of_study_opt: Option<String>,
|
field_of_study_opt: Option<String>,
|
||||||
) -> Result<Vec<ApplicationResult>, DbErr> {
|
) -> Result<Vec<CandidateParentResult>, DbErr> {
|
||||||
let select = Candidate::find();
|
let select = Candidate::find();
|
||||||
if let Some(study) = field_of_study_opt {
|
if let Some(study) = field_of_study_opt {
|
||||||
select.filter(candidate::Column::Study.eq(study))
|
select.filter(candidate::Column::Study.eq(study))
|
||||||
|
|
@ -40,7 +40,7 @@ impl Query {
|
||||||
.join(JoinType::InnerJoin, candidate::Relation::Parent.def())
|
.join(JoinType::InnerJoin, candidate::Relation::Parent.def())
|
||||||
.column_as(parent::Column::Name, "parent_name")
|
.column_as(parent::Column::Name, "parent_name")
|
||||||
.column_as(parent::Column::Surname, "parent_surname")
|
.column_as(parent::Column::Surname, "parent_surname")
|
||||||
.into_model::<ApplicationResult>()
|
.into_model::<CandidateParentResult>()
|
||||||
.paginate(db, PAGE_SIZE)
|
.paginate(db, PAGE_SIZE)
|
||||||
.fetch()
|
.fetch()
|
||||||
.await
|
.await
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue