Skip to content

Commit 6f50210

Browse files
committed
Remove version_authors
1 parent 4125597 commit 6f50210

File tree

16 files changed

+31
-106
lines changed

16 files changed

+31
-106
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CREATE TABLE version_authors
2+
(
3+
id SERIAL NOT NULL
4+
CONSTRAINT version_authors_pkey
5+
PRIMARY KEY,
6+
version_id INTEGER NOT NULL
7+
CONSTRAINT fk_version_authors_version_id
8+
REFERENCES versions
9+
ON DELETE CASCADED,
10+
name VARCHAR NOT NULL
11+
);
12+
13+
CREATE
14+
INDEX index_version_authors_version_id
15+
ON version_authors (version_id);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
DROP TABLE version_authors;

mirage/route-handlers/crates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export function register(server) {
135135
let version = schema.versions.findBy({ crateId, num });
136136
if (!version) return { errors: [{ detail: `crate \`${crateId}\` does not have a version \`${num}\`` }] };
137137

138-
return { meta: { names: version._authors }, users: [] };
138+
return { meta: { names: [] }, users: [] };
139139
});
140140

141141
server.get('/api/v1/crates/:crate_id/:version_num/dependencies', (schema, request) => {

src/bin/monitor.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ fn check_stalled_update_downloads(conn: &PgConnection) -> Result<()> {
110110
fn check_spam_attack(conn: &PgConnection) -> Result<()> {
111111
use cargo_registry::models::krate::canon_crate_name;
112112
use diesel::dsl::*;
113-
use diesel::sql_types::Bool;
114113

115114
const EVENT_KEY: &str = "spam_attack";
116115

@@ -121,11 +120,6 @@ fn check_spam_attack(conn: &PgConnection) -> Result<()> {
121120
.as_ref()
122121
.map(|s| s.split(',').collect())
123122
.unwrap_or_default();
124-
let bad_author_patterns = dotenv::var("SPAM_AUTHOR_PATTERNS");
125-
let bad_author_patterns: Vec<_> = bad_author_patterns
126-
.as_ref()
127-
.map(|s| s.split(',').collect())
128-
.unwrap_or_default();
129123

130124
let mut event_description = None;
131125

@@ -139,19 +133,6 @@ fn check_spam_attack(conn: &PgConnection) -> Result<()> {
139133
event_description = Some(format!("Crate named {} published", bad_crate));
140134
}
141135

142-
let mut query = version_authors::table
143-
.select(version_authors::name)
144-
.filter(false.into_sql::<Bool>()) // Never return anything if we have no patterns
145-
.into_boxed();
146-
for author_pattern in bad_author_patterns {
147-
query = query.or_filter(version_authors::name.like(author_pattern));
148-
}
149-
let bad_author: Option<String> = query.first(conn).optional()?;
150-
151-
if let Some(bad_author) = bad_author {
152-
event_description = Some(format!("Crate with author {} published", bad_author));
153-
}
154-
155136
let event = if let Some(event_description) = event_description {
156137
on_call::Event::Trigger {
157138
incident_key: Some(EVENT_KEY.into()),

src/controllers/krate/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn publish(req: &mut dyn RequestExt) -> EndpointResult {
160160
file_length as i32,
161161
user.id,
162162
)?
163-
.save(&conn, &new_crate.authors, &verified_email_address)?;
163+
.save(&conn, &verified_email_address)?;
164164

165165
insert_version_owner_action(
166166
&conn,

src/downloads_counter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ mod tests {
452452
self.user.id,
453453
)
454454
.expect("failed to create version")
455-
.save(conn, &[], "[email protected]")
455+
.save(conn, "[email protected]")
456456
.expect("failed to save version");
457457

458458
self.next_version += 1;

src/models/version.rs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,7 @@ impl NewVersion {
136136
Ok(new_version)
137137
}
138138

139-
pub fn save(
140-
&self,
141-
conn: &PgConnection,
142-
authors: &[String],
143-
published_by_email: &str,
144-
) -> AppResult<Version> {
145-
use crate::schema::version_authors::{name, version_id};
139+
pub fn save(&self, conn: &PgConnection, published_by_email: &str) -> AppResult<Version> {
146140
use crate::schema::versions::dsl::*;
147141
use diesel::dsl::exists;
148142
use diesel::{insert_into, select};
@@ -167,15 +161,6 @@ impl NewVersion {
167161
versions_published_by::email.eq(published_by_email),
168162
))
169163
.execute(conn)?;
170-
171-
let new_authors = authors
172-
.iter()
173-
.map(|s| (version_id.eq(version.id), name.eq(s)))
174-
.collect::<Vec<_>>();
175-
176-
insert_into(version_authors::table)
177-
.values(&new_authors)
178-
.execute(conn)?;
179164
Ok(version)
180165
})
181166
}

src/schema.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ index df884e4..18e08cd 100644
2020
- path -> Ltree,
2121
}
2222
}
23-
23+
2424
@@ -678,6 +674,24 @@
2525
}
26-
26+
2727
table! {
2828
+ /// Representation of the `recent_crate_downloads` view.
2929
+ ///
@@ -45,7 +45,7 @@ index df884e4..18e08cd 100644
4545
+table! {
4646
use diesel::sql_types::*;
4747
use diesel_full_text_search::{TsVector as Tsvector};
48-
48+
4949
@@ -1003,7 +1017,8 @@
5050
joinable!(badges -> crates (crate_id));
5151
joinable!(crate_owner_invitations -> crates (crate_id));

src/schema.rs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -814,35 +814,6 @@ table! {
814814
}
815815
}
816816

817-
table! {
818-
use diesel::sql_types::*;
819-
use diesel_full_text_search::{TsVector as Tsvector};
820-
821-
/// Representation of the `version_authors` table.
822-
///
823-
/// (Automatically generated by Diesel.)
824-
version_authors (id) {
825-
/// The `id` column of the `version_authors` table.
826-
///
827-
/// Its SQL type is `Int4`.
828-
///
829-
/// (Automatically generated by Diesel.)
830-
id -> Int4,
831-
/// The `version_id` column of the `version_authors` table.
832-
///
833-
/// Its SQL type is `Int4`.
834-
///
835-
/// (Automatically generated by Diesel.)
836-
version_id -> Int4,
837-
/// The `name` column of the `version_authors` table.
838-
///
839-
/// Its SQL type is `Varchar`.
840-
///
841-
/// (Automatically generated by Diesel.)
842-
name -> Varchar,
843-
}
844-
}
845-
846817
table! {
847818
use diesel::sql_types::*;
848819
use diesel_full_text_search::{TsVector as Tsvector};
@@ -1050,7 +1021,6 @@ joinable!(publish_limit_buckets -> users (user_id));
10501021
joinable!(publish_rate_overrides -> users (user_id));
10511022
joinable!(readme_renderings -> versions (version_id));
10521023
joinable!(recent_crate_downloads -> crates (crate_id));
1053-
joinable!(version_authors -> versions (version_id));
10541024
joinable!(version_downloads -> versions (version_id));
10551025
joinable!(version_owner_actions -> api_tokens (api_token_id));
10561026
joinable!(version_owner_actions -> users (user_id));
@@ -1081,7 +1051,6 @@ allow_tables_to_appear_in_same_query!(
10811051
reserved_crate_names,
10821052
teams,
10831053
users,
1084-
version_authors,
10851054
version_downloads,
10861055
version_owner_actions,
10871056
versions,

src/tasks/dump_db/dump-db.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,6 @@ account_lock_until = "private"
179179
[users.column_defaults]
180180
gh_access_token = "''"
181181

182-
[version_authors]
183-
dependencies = ["versions"]
184-
[version_authors.columns]
185-
id = "public"
186-
version_id = "public"
187-
name = "public"
188-
189182
[version_downloads]
190183
dependencies = ["versions"]
191184
[version_downloads.columns]

src/tasks/update_downloads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ mod test {
110110
user_id,
111111
)
112112
.unwrap();
113-
let version = version.save(conn, &[], "[email protected]").unwrap();
113+
let version = version.save(conn, "[email protected]").unwrap();
114114
(krate, version)
115115
}
116116

src/tests/builders/publish.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ lazy_static! {
2424
/// a crate to exist and don't need to test behavior caused by the publish request, inserting
2525
/// a crate into the database directly by using CrateBuilder will be faster.
2626
pub struct PublishBuilder {
27-
authors: Vec<String>,
2827
badges: HashMap<String, HashMap<String, String>>,
2928
categories: Vec<String>,
3029
deps: Vec<u::EncodableCrateDependency>,
@@ -44,7 +43,6 @@ impl PublishBuilder {
4443
/// in its tarball.
4544
pub fn new(krate_name: &str) -> Self {
4645
PublishBuilder {
47-
authors: vec!["foo".to_string()],
4846
badges: HashMap::new(),
4947
categories: vec![],
5048
deps: vec![],
@@ -168,25 +166,12 @@ impl PublishBuilder {
168166
self
169167
}
170168

171-
/// Add an author to this crate
172-
pub fn author(mut self, author: &str) -> Self {
173-
self.authors.push(author.into());
174-
self
175-
}
176-
177-
/// Remove the authors from this crate. Publish will fail unless authors are reset.
178-
pub fn unset_authors(mut self) -> Self {
179-
self.authors = vec![];
180-
self
181-
}
182-
183169
pub fn build(self) -> (String, Vec<u8>) {
184170
let new_crate = u::EncodableCrateUpload {
185171
name: u::EncodableCrateName(self.krate_name.clone()),
186172
vers: u::EncodableCrateVersion(self.version),
187173
features: HashMap::new(),
188174
deps: self.deps,
189-
authors: self.authors,
190175
description: self.desc,
191176
homepage: None,
192177
documentation: self.doc_url,

src/tests/builders/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl<'a> VersionBuilder<'a> {
9292
self.size,
9393
published_by,
9494
)?
95-
.save(connection, &[], "[email protected]")?;
95+
.save(connection, "[email protected]")?;
9696

9797
if self.yanked {
9898
vers = update(&vers)

src/tests/krate/publish.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -703,23 +703,23 @@ fn bad_keywords() {
703703
assert_eq!(response.status(), StatusCode::OK);
704704
assert_eq!(
705705
response.json(),
706-
json!({ "errors": [{ "detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 221" }] })
706+
json!({ "errors": [{ "detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 203" }] })
707707
);
708708

709709
let crate_to_publish = PublishBuilder::new("foo_bad_key").keyword("?@?%");
710710
let response = token.enqueue_publish(crate_to_publish);
711711
assert_eq!(response.status(), StatusCode::OK);
712712
assert_eq!(
713713
response.json(),
714-
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"?@?%\", expected a valid keyword specifier at line 1 column 196" }] })
714+
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"?@?%\", expected a valid keyword specifier at line 1 column 178" }] })
715715
);
716716

717717
let crate_to_publish = PublishBuilder::new("foo_bad_key").keyword("áccênts");
718718
let response = token.enqueue_publish(crate_to_publish);
719719
assert_eq!(response.status(), StatusCode::OK);
720720
assert_eq!(
721721
response.json(),
722-
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"áccênts\", expected a valid keyword specifier at line 1 column 201" }] })
722+
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"áccênts\", expected a valid keyword specifier at line 1 column 183" }] })
723723
);
724724
}
725725

@@ -824,8 +824,7 @@ fn license_and_description_required() {
824824
let crate_to_publish = PublishBuilder::new("foo_metadata")
825825
.version("1.1.0")
826826
.unset_license()
827-
.unset_description()
828-
.unset_authors();
827+
.unset_description();
829828

830829
let response = token.enqueue_publish(crate_to_publish);
831830
assert_eq!(response.status(), StatusCode::OK);
@@ -836,9 +835,7 @@ fn license_and_description_required() {
836835

837836
let crate_to_publish = PublishBuilder::new("foo_metadata")
838837
.version("1.1.0")
839-
.unset_description()
840-
.unset_authors()
841-
.author("");
838+
.unset_description();
842839

843840
let response = token.enqueue_publish(crate_to_publish);
844841
assert_eq!(response.status(), StatusCode::OK);

src/views/krate_publish.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pub struct EncodableCrateUpload {
1818
pub vers: EncodableCrateVersion,
1919
pub deps: Vec<EncodableCrateDependency>,
2020
pub features: HashMap<EncodableFeatureName, Vec<EncodableFeature>>,
21-
pub authors: Vec<String>,
2221
pub description: Option<String>,
2322
pub homepage: Option<String>,
2423
pub documentation: Option<String>,

tests/mirage/crates-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ module('Mirage | Crates', function (hooks) {
691691
let responsePayload = await response.json();
692692
assert.deepEqual(responsePayload, {
693693
meta: {
694-
names: authors,
694+
names: [],
695695
},
696696
users: [],
697697
});

0 commit comments

Comments
 (0)