File tree Expand file tree Collapse file tree 1 file changed +5
-17
lines changed Expand file tree Collapse file tree 1 file changed +5
-17
lines changed Original file line number Diff line number Diff line change @@ -388,29 +388,17 @@ pub fn show(req: &mut Request) -> CargoResult<Response> {
388
388
389
389
/// Handles the `GET /category_slugs` route.
390
390
pub fn slugs ( req : & mut Request ) -> CargoResult < Response > {
391
- let conn = req. tx ( ) ?;
392
- let stmt = conn. prepare (
393
- "SELECT slug FROM categories \
394
- ORDER BY slug",
395
- ) ?;
396
- let rows = stmt. query ( & [ ] ) ?;
391
+ let conn = req. db_conn ( ) ?;
392
+ let slugs = categories:: table
393
+ . select ( ( categories:: slug, categories:: slug) )
394
+ . load ( & * conn) ?;
397
395
398
- #[ derive( RustcEncodable ) ]
396
+ #[ derive( RustcEncodable , Queryable ) ]
399
397
struct Slug {
400
398
id : String ,
401
399
slug : String ,
402
400
}
403
401
404
- let slugs: Vec < Slug > = rows. iter ( )
405
- . map ( |r| {
406
- let slug: String = r. get ( "slug" ) ;
407
- Slug {
408
- id : slug. clone ( ) ,
409
- slug : slug,
410
- }
411
- } )
412
- . collect ( ) ;
413
-
414
402
#[ derive( RustcEncodable ) ]
415
403
struct R {
416
404
category_slugs : Vec < Slug > ,
You can’t perform that action at this time.
0 commit comments