@@ -60,7 +60,7 @@ impl Category {
60
60
pub fn find_by_category ( conn : & GenericConnection , name : & str ) -> CargoResult < Category > {
61
61
let stmt = conn. prepare (
62
62
"SELECT * FROM categories \
63
- WHERE category = $1",
63
+ WHERE category = $1",
64
64
) ?;
65
65
let rows = stmt. query ( & [ & name] ) ?;
66
66
rows. iter ( ) . next ( ) . chain_error ( || NotFound ) . map ( |row| {
@@ -71,7 +71,7 @@ impl Category {
71
71
pub fn find_by_slug ( conn : & GenericConnection , slug : & str ) -> CargoResult < Category > {
72
72
let stmt = conn. prepare (
73
73
"SELECT * FROM categories \
74
- WHERE slug = LOWER($1)",
74
+ WHERE slug = LOWER($1)",
75
75
) ?;
76
76
let rows = stmt. query ( & [ & slug] ) ?;
77
77
rows. iter ( ) . next ( ) . chain_error ( || NotFound ) . map ( |row| {
@@ -168,8 +168,8 @@ impl Category {
168
168
if !to_rm. is_empty ( ) {
169
169
conn. execute (
170
170
"DELETE FROM crates_categories \
171
- WHERE category_id = ANY($1) \
172
- AND crate_id = $2",
171
+ WHERE category_id = ANY($1) \
172
+ AND crate_id = $2",
173
173
& [ & to_rm, & krate. id ] ,
174
174
) ?;
175
175
}
@@ -183,7 +183,7 @@ impl Category {
183
183
conn. execute (
184
184
& format ! (
185
185
"INSERT INTO crates_categories \
186
- (crate_id, category_id) VALUES {}",
186
+ (crate_id, category_id) VALUES {}",
187
187
insert
188
188
) ,
189
189
& [ ] ,
@@ -196,9 +196,9 @@ impl Category {
196
196
pub fn count_toplevel ( conn : & GenericConnection ) -> CargoResult < i64 > {
197
197
let sql = format ! (
198
198
"\
199
- SELECT COUNT(*) \
200
- FROM {} \
201
- WHERE category NOT LIKE '%::%'",
199
+ SELECT COUNT(*) \
200
+ FROM {} \
201
+ WHERE category NOT LIKE '%::%'",
202
202
Model :: table_name( None :: <Self >)
203
203
) ;
204
204
let stmt = conn. prepare ( & sql) ?;
@@ -272,16 +272,16 @@ impl Category {
272
272
pub fn subcategories ( & self , conn : & GenericConnection ) -> CargoResult < Vec < Category > > {
273
273
let stmt = conn. prepare (
274
274
"\
275
- SELECT c.id, c.category, c.slug, c.description, c.created_at, \
276
- COALESCE (( \
277
- SELECT sum(c2.crates_cnt)::int \
278
- FROM categories as c2 \
279
- WHERE c2.slug = c.slug \
280
- OR c2.slug LIKE c.slug || '::%' \
281
- ), 0) as crates_cnt \
282
- FROM categories as c \
283
- WHERE c.category ILIKE $1 || '::%' \
284
- AND c.category NOT ILIKE $1 || '::%::%'",
275
+ SELECT c.id, c.category, c.slug, c.description, c.created_at, \
276
+ COALESCE (( \
277
+ SELECT sum(c2.crates_cnt)::int \
278
+ FROM categories as c2 \
279
+ WHERE c2.slug = c.slug \
280
+ OR c2.slug LIKE c.slug || '::%' \
281
+ ), 0) as crates_cnt \
282
+ FROM categories as c \
283
+ WHERE c.category ILIKE $1 || '::%' \
284
+ AND c.category NOT ILIKE $1 || '::%::%'",
285
285
) ?;
286
286
287
287
let rows = stmt. query ( & [ & self . category ] ) ?;
@@ -391,7 +391,7 @@ pub fn slugs(req: &mut Request) -> CargoResult<Response> {
391
391
let conn = req. tx ( ) ?;
392
392
let stmt = conn. prepare (
393
393
"SELECT slug FROM categories \
394
- ORDER BY slug",
394
+ ORDER BY slug",
395
395
) ?;
396
396
let rows = stmt. query ( & [ ] ) ?;
397
397
0 commit comments