Skip to content

Commit ccc7a40

Browse files
committed
Remove the User as Author from the back end.
1 parent 78ddcf5 commit ccc7a40

File tree

1 file changed

+11
-20
lines changed

1 file changed

+11
-20
lines changed

src/version.rs

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use time::Duration;
1010
use time::Timespec;
1111
use url;
1212

13-
use {Model, Crate, User};
13+
use {Model, Crate};
1414
use app::RequestApp;
1515
use db::RequestTransaction;
1616
use dependency::{Dependency, EncodableDependency, Kind};
@@ -33,9 +33,8 @@ pub struct Version {
3333
pub yanked: bool,
3434
}
3535

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
3938
}
4039

4140
#[derive(RustcEncodable, RustcDecodable)]
@@ -170,14 +169,9 @@ impl Version {
170169
WHERE version_id = $1
171170
ORDER BY name ASC")?;
172171
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())
181175
}
182176

183177
pub fn add_author(&self,
@@ -327,19 +321,16 @@ pub fn downloads(req: &mut Request) -> CargoResult<Response> {
327321
pub fn authors(req: &mut Request) -> CargoResult<Response> {
328322
let (version, _) = version_and_crate(req)?;
329323
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();
337325

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.
338329
#[derive(RustcEncodable)]
339330
struct R { users: Vec<::user::EncodableUser>, meta: Meta }
340331
#[derive(RustcEncodable)]
341332
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 } }))
343334
}
344335

345336
/// Handles the `DELETE /crates/:crate_id/:version/yank` route.

0 commit comments

Comments
 (0)