Skip to content

Commit 5798a31

Browse files
committed
feat: implement pending version resubmitting
1 parent 922df22 commit 5798a31

File tree

7 files changed

+361
-112
lines changed

7 files changed

+361
-112
lines changed

src/endpoints/mod_versions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pub async fn create_version(
253253
let dev = auth.developer()?;
254254
let mut pool = data.db.acquire().await.or(Err(ApiError::DbAcquireError))?;
255255

256-
let fetched_mod = Mod::get_one(&path.id, true, &mut pool).await?;
256+
let fetched_mod = Mod::get_one(&path.id, false, &mut pool).await?;
257257

258258
if fetched_mod.is_none() {
259259
return Err(ApiError::NotFound(format!("Mod {} not found", path.id)));

src/types/models/dependency.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,27 @@ impl Dependency {
128128
Ok(())
129129
}
130130

131+
pub async fn clear_for_mod_version(
132+
id: i32,
133+
pool: &mut PgConnection
134+
) -> Result<(), ApiError> {
135+
sqlx::query!(
136+
"DELETE FROM dependencies
137+
WHERE dependent_id = $1",
138+
id
139+
)
140+
.execute(&mut *pool)
141+
.await
142+
.map(|_| ())
143+
.map_err(|err| {
144+
log::error!(
145+
"Failed to remove dependencies for mod version {}: {}",
146+
id, err
147+
);
148+
ApiError::DbError
149+
})
150+
}
151+
131152
pub async fn get_for_mod_versions(
132153
ids: &Vec<i32>,
133154
platform: Option<VerPlatform>,

src/types/models/incompatibility.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,27 @@ impl Incompatibility {
110110
Ok(())
111111
}
112112

113+
pub async fn clear_for_mod_version(
114+
id: i32,
115+
pool: &mut PgConnection
116+
) -> Result<(), ApiError> {
117+
sqlx::query!(
118+
"DELETE FROM incompatibilities
119+
WHERE mod_id = $1",
120+
id
121+
)
122+
.execute(&mut *pool)
123+
.await
124+
.map(|_| ())
125+
.map_err(|err| {
126+
log::error!(
127+
"Failed to remove incompatibilities for mod version {}: {}",
128+
id, err
129+
);
130+
ApiError::DbError
131+
})
132+
}
133+
113134
pub async fn get_for_mod_version(
114135
id: i32,
115136
pool: &mut PgConnection,

0 commit comments

Comments
 (0)