Skip to content

Commit 6347fbb

Browse files
authored
controllers/krate/search: Add some type aliases (#9709)
1 parent 52fe8a0 commit 6347fbb

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/controllers/krate/search.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ pub async fn search(app: AppState, req: Parts) -> AppResult<Json<Value>> {
185185
pagination,
186186
filter_params.make_query(&req, conn)?.count(),
187187
);
188-
let data: Paginated<(Crate, bool, i64, Option<i64>, f32)> =
188+
let data: Paginated<Record> =
189189
info_span!("db.query", message = "SELECT ..., COUNT(*) FROM crates")
190190
.in_scope(|| query.load(conn))?;
191191

@@ -202,7 +202,7 @@ pub async fn search(app: AppState, req: Parts) -> AppResult<Json<Value>> {
202202
pagination,
203203
filter_params.make_query(&req, conn)?.count(),
204204
);
205-
let data: Paginated<(Crate, bool, i64, Option<i64>, f32)> =
205+
let data: Paginated<Record> =
206206
info_span!("db.query", message = "SELECT ..., COUNT(*) FROM crates")
207207
.in_scope(|| query.load(conn))?;
208208
(
@@ -571,6 +571,7 @@ impl<'a> FilterParams<'a> {
571571
}
572572

573573
mod seek {
574+
use super::Record;
574575
use crate::controllers::helpers::pagination::seek;
575576
use crate::models::Crate;
576577
use chrono::naive::serde::ts_microseconds;
@@ -611,10 +612,7 @@ mod seek {
611612
);
612613

613614
impl Seek {
614-
pub(crate) fn to_payload(
615-
&self,
616-
record: &(Crate, bool, i64, Option<i64>, f32),
617-
) -> SeekPayload {
615+
pub(crate) fn to_payload(&self, record: &Record) -> SeekPayload {
618616
let (
619617
Crate {
620618
id,
@@ -648,15 +646,16 @@ mod seek {
648646
}
649647
}
650648

649+
type Record = (Crate, bool, i64, Option<i64>, f32);
650+
651+
type QuerySource = LeftJoinQuerySource<
652+
InnerJoinQuerySource<crates::table, crate_downloads::table>,
653+
recent_crate_downloads::table,
654+
>;
655+
651656
type BoxedCondition<'a> = Box<
652-
dyn BoxableExpression<
653-
LeftJoinQuerySource<
654-
InnerJoinQuerySource<crates::table, crate_downloads::table>,
655-
recent_crate_downloads::table,
656-
>,
657-
diesel::pg::Pg,
658-
SqlType = diesel::sql_types::Nullable<Bool>,
659-
> + 'a,
657+
dyn BoxableExpression<QuerySource, diesel::pg::Pg, SqlType = diesel::sql_types::Nullable<Bool>>
658+
+ 'a,
660659
>;
661660

662661
diesel::infix_operator!(Contains, "@>");

0 commit comments

Comments
 (0)