Skip to content

Commit

Permalink
delete unused stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Fleeym committed Feb 17, 2024
1 parent 72a887b commit c3ce0f5
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 53 deletions.
1 change: 0 additions & 1 deletion src/types/mod_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::io::{Cursor, Read};
use actix_web::web::Bytes;
use semver::Version;
use serde::Deserialize;
use sqlx::PgConnection;
use std::io::BufReader;
use zip::read::ZipFile;

Expand Down
53 changes: 1 addition & 52 deletions src/types/models/mod_entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
use actix_web::web::Bytes;
use serde::Serialize;
use sqlx::{PgConnection, Postgres, QueryBuilder};
use std::{collections::HashMap, io::Cursor, str::FromStr};
use std::{io::Cursor, str::FromStr};

use super::{
developer::{Developer, FetchedDeveloper, ModDeveloper},
Expand Down Expand Up @@ -292,57 +292,6 @@ impl Mod {
Ok(())
}

pub async fn get_all_version_strings_for_mod(
id: &str,
pool: &mut PgConnection,
) -> Result<Vec<String>, ApiError> {
let result = match sqlx::query!(
"SELECT version FROM mod_versions WHERE mod_id = $1 AND validated = true",
id
)
.fetch_all(&mut *pool)
.await
{
Ok(r) => r,
Err(e) => {
log::error!("{}", e);
return Err(ApiError::DbError);
}
};
Ok(result.iter().map(|x| x.version.clone()).collect())
}

pub async fn get_all_version_strings_for_mods(
ids: Vec<String>,
pool: &mut PgConnection,
) -> Result<HashMap<String, Vec<String>>, ApiError> {
let mut ret: HashMap<String, Vec<String>> = HashMap::new();
if ids.is_empty() {
return Ok(ret);
}
let result = match sqlx::query!(
"SELECT version, mod_id FROM mod_versions WHERE mod_id = ANY($1) AND validated = true",
&ids
)
.fetch_all(&mut *pool)
.await
{
Ok(r) => r,
Err(e) => {
log::error!("{}", e);
return Err(ApiError::DbError);
}
};
for i in result {
if ret.contains_key(&i.mod_id) {
ret.get_mut(&i.mod_id).unwrap().push(i.version);
} else {
ret.insert(i.mod_id.clone(), vec![i.version]);
}
}
Ok(ret)
}

pub async fn new_version(
json: &ModJson,
developer: FetchedDeveloper,
Expand Down

0 comments on commit c3ce0f5

Please sign in to comment.