@@ -10,7 +10,7 @@ use time::Duration;
10
10
use time:: Timespec ;
11
11
use url;
12
12
13
- use { Model , Crate , User } ;
13
+ use { Model , Crate } ;
14
14
use app:: RequestApp ;
15
15
use db:: RequestTransaction ;
16
16
use dependency:: { Dependency , EncodableDependency , Kind } ;
@@ -33,9 +33,8 @@ pub struct Version {
33
33
pub yanked : bool ,
34
34
}
35
35
36
- pub enum Author {
37
- User ( User ) , //TODO: not used. this should be removed.
38
- Name ( String ) ,
36
+ pub struct Author {
37
+ pub name : String
39
38
}
40
39
41
40
#[ derive( RustcEncodable , RustcDecodable ) ]
@@ -170,14 +169,9 @@ impl Version {
170
169
WHERE version_id = $1
171
170
ORDER BY name ASC" ) ?;
172
171
let rows = stmt. query ( & [ & self . id ] ) ?;
173
- rows. into_iter ( ) . map ( |row| {
174
- let user_id: Option < i32 > = row. get ( "user_id" ) ;
175
- let name: String = row. get ( "name" ) ;
176
- Ok ( match user_id {
177
- Some ( id) => Author :: User ( User :: find ( conn, id) ?) ,
178
- None => Author :: Name ( name) ,
179
- } )
180
- } ) . collect ( )
172
+ Ok ( rows. into_iter ( ) . map ( |row| {
173
+ Author { name : row. get ( "name" ) }
174
+ } ) . collect ( ) )
181
175
}
182
176
183
177
pub fn add_author ( & self ,
@@ -327,19 +321,16 @@ pub fn downloads(req: &mut Request) -> CargoResult<Response> {
327
321
pub fn authors ( req : & mut Request ) -> CargoResult < Response > {
328
322
let ( version, _) = version_and_crate ( req) ?;
329
323
let tx = req. tx ( ) ?;
330
- let ( mut users, mut names) = ( Vec :: new ( ) , Vec :: new ( ) ) ;
331
- for author in version. authors ( tx) ?. into_iter ( ) {
332
- match author {
333
- Author :: User ( u) => users. push ( u. encodable ( ) ) ,
334
- Author :: Name ( n) => names. push ( n) ,
335
- }
336
- }
324
+ let names = version. authors ( tx) ?. into_iter ( ) . map ( |a| a. name ) . collect ( ) ;
337
325
326
+ // It was imagined that we wold associate authors with users.
327
+ // This was never implemented. This complicated return struct
328
+ // is all that is left, hear for backwards compatibility.
338
329
#[ derive( RustcEncodable ) ]
339
330
struct R { users : Vec < :: user:: EncodableUser > , meta : Meta }
340
331
#[ derive( RustcEncodable ) ]
341
332
struct Meta { names : Vec < String > }
342
- Ok ( req. json ( & R { users : users , meta : Meta { names : names } } ) )
333
+ Ok ( req. json ( & R { users : vec ! [ ] , meta : Meta { names : names } } ) )
343
334
}
344
335
345
336
/// Handles the `DELETE /crates/:crate_id/:version/yank` route.
0 commit comments