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]

0 commit comments

Comments
 (0)