You've already forked AstralRinth
forked from didirus/AstralRinth
Add loaders + game versions param to mods (#528)
This commit is contained in:
2
.idea/sqldialects.xml
generated
2
.idea/sqldialects.xml
generated
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="SqlDialectMappings">
|
<component name="SqlDialectMappings">
|
||||||
<file url="file://$PROJECT_DIR$/migrations/20230104214503_random-projects.sql" dialect="PostgreSQL" />
|
<file url="PROJECT" dialect="PostgreSQL" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
21
migrations/20230127233123_loader-gv-mod.sql
Normal file
21
migrations/20230127233123_loader-gv-mod.sql
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
-- Add migration script here
|
||||||
|
ALTER TABLE mods ADD COLUMN loaders varchar(255)[] NOT NULL default array[]::varchar[];
|
||||||
|
ALTER TABLE mods ADD COLUMN game_versions varchar(255)[] NOT NULL default array[]::varchar[];
|
||||||
|
|
||||||
|
UPDATE mods
|
||||||
|
SET loaders = (
|
||||||
|
SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])
|
||||||
|
FROM versions v
|
||||||
|
INNER JOIN loaders_versions lv ON lv.version_id = v.id
|
||||||
|
INNER JOIN loaders l on lv.loader_id = l.id
|
||||||
|
WHERE v.mod_id = mods.id
|
||||||
|
);
|
||||||
|
|
||||||
|
UPDATE mods
|
||||||
|
SET game_versions = (
|
||||||
|
SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])
|
||||||
|
FROM versions v
|
||||||
|
INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
|
||||||
|
INNER JOIN game_versions gv on gvv.game_version_id = gv.id
|
||||||
|
WHERE v.mod_id = mods.id
|
||||||
|
);
|
||||||
1821
sqlx-data.json
1821
sqlx-data.json
File diff suppressed because it is too large
Load Diff
@@ -139,6 +139,8 @@ impl ProjectBuilder {
|
|||||||
flame_anvil_user: None,
|
flame_anvil_user: None,
|
||||||
webhook_sent: false,
|
webhook_sent: false,
|
||||||
color: self.color,
|
color: self.color,
|
||||||
|
loaders: vec![],
|
||||||
|
game_versions: vec![],
|
||||||
};
|
};
|
||||||
project_struct.insert(&mut *transaction).await?;
|
project_struct.insert(&mut *transaction).await?;
|
||||||
|
|
||||||
@@ -181,6 +183,10 @@ impl ProjectBuilder {
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Project::update_game_versions(self.project_id, &mut *transaction)
|
||||||
|
.await?;
|
||||||
|
Project::update_loaders(self.project_id, &mut *transaction).await?;
|
||||||
|
|
||||||
Ok(self.project_id)
|
Ok(self.project_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -216,6 +222,8 @@ pub struct Project {
|
|||||||
pub flame_anvil_user: Option<UserId>,
|
pub flame_anvil_user: Option<UserId>,
|
||||||
pub webhook_sent: bool,
|
pub webhook_sent: bool,
|
||||||
pub color: Option<u32>,
|
pub color: Option<u32>,
|
||||||
|
pub loaders: Vec<String>,
|
||||||
|
pub game_versions: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Project {
|
impl Project {
|
||||||
@@ -283,7 +291,7 @@ impl Project {
|
|||||||
issues_url, source_url, wiki_url, discord_url, license_url,
|
issues_url, source_url, wiki_url, discord_url, license_url,
|
||||||
team_id, client_side, server_side, license, slug,
|
team_id, client_side, server_side, license, slug,
|
||||||
moderation_message, moderation_message_body, flame_anvil_project,
|
moderation_message, moderation_message_body, flame_anvil_project,
|
||||||
flame_anvil_user, webhook_sent, color
|
flame_anvil_user, webhook_sent, color, loaders, game_versions
|
||||||
FROM mods
|
FROM mods
|
||||||
WHERE id = $1
|
WHERE id = $1
|
||||||
",
|
",
|
||||||
@@ -326,6 +334,8 @@ impl Project {
|
|||||||
flame_anvil_user: row.flame_anvil_user.map(UserId),
|
flame_anvil_user: row.flame_anvil_user.map(UserId),
|
||||||
webhook_sent: row.webhook_sent,
|
webhook_sent: row.webhook_sent,
|
||||||
color: row.color.map(|x| x as u32),
|
color: row.color.map(|x| x as u32),
|
||||||
|
loaders: row.loaders,
|
||||||
|
game_versions: row.game_versions,
|
||||||
}))
|
}))
|
||||||
} else {
|
} else {
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@@ -351,7 +361,7 @@ impl Project {
|
|||||||
issues_url, source_url, wiki_url, discord_url, license_url,
|
issues_url, source_url, wiki_url, discord_url, license_url,
|
||||||
team_id, client_side, server_side, license, slug,
|
team_id, client_side, server_side, license, slug,
|
||||||
moderation_message, moderation_message_body, flame_anvil_project,
|
moderation_message, moderation_message_body, flame_anvil_project,
|
||||||
flame_anvil_user, webhook_sent, color
|
flame_anvil_user, webhook_sent, color, loaders, game_versions
|
||||||
FROM mods
|
FROM mods
|
||||||
WHERE id = ANY($1)
|
WHERE id = ANY($1)
|
||||||
",
|
",
|
||||||
@@ -394,6 +404,8 @@ impl Project {
|
|||||||
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
||||||
webhook_sent: m.webhook_sent,
|
webhook_sent: m.webhook_sent,
|
||||||
color: m.color.map(|x| x as u32),
|
color: m.color.map(|x| x as u32),
|
||||||
|
loaders: m.loaders,
|
||||||
|
game_versions: m.game_versions,
|
||||||
}))
|
}))
|
||||||
})
|
})
|
||||||
.try_collect::<Vec<Project>>()
|
.try_collect::<Vec<Project>>()
|
||||||
@@ -673,6 +685,7 @@ impl Project {
|
|||||||
m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,
|
m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,
|
||||||
m.team_id team_id, m.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
|
m.team_id team_id, m.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
|
||||||
cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.flame_anvil_project flame_anvil_project, m.flame_anvil_user flame_anvil_user, m.webhook_sent webhook_sent, m.color,
|
cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.flame_anvil_project flame_anvil_project, m.flame_anvil_user flame_anvil_user, m.webhook_sent webhook_sent, m.color,
|
||||||
|
m.loaders loaders, m.game_versions game_versions,
|
||||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,
|
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,
|
||||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,
|
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,
|
||||||
JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,
|
JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,
|
||||||
@@ -732,6 +745,8 @@ impl Project {
|
|||||||
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
||||||
webhook_sent: m.webhook_sent,
|
webhook_sent: m.webhook_sent,
|
||||||
color: m.color.map(|x| x as u32),
|
color: m.color.map(|x| x as u32),
|
||||||
|
loaders: m.loaders,
|
||||||
|
game_versions: m.game_versions,
|
||||||
},
|
},
|
||||||
project_type: m.project_type_name,
|
project_type: m.project_type_name,
|
||||||
categories: m.categories.unwrap_or_default(),
|
categories: m.categories.unwrap_or_default(),
|
||||||
@@ -802,6 +817,7 @@ impl Project {
|
|||||||
m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,
|
m.issues_url issues_url, m.source_url source_url, m.wiki_url wiki_url, m.discord_url discord_url, m.license_url license_url,
|
||||||
m.team_id team_id, m.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
|
m.team_id team_id, m.client_side client_side, m.server_side server_side, m.license license, m.slug slug, m.moderation_message moderation_message, m.moderation_message_body moderation_message_body,
|
||||||
cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.flame_anvil_project flame_anvil_project, m.flame_anvil_user flame_anvil_user, m.webhook_sent, m.color,
|
cs.name client_side_type, ss.name server_side_type, pt.name project_type_name, m.flame_anvil_project flame_anvil_project, m.flame_anvil_user flame_anvil_user, m.webhook_sent, m.color,
|
||||||
|
m.loaders loaders, m.game_versions game_versions,
|
||||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,
|
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is false) categories,
|
||||||
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,
|
ARRAY_AGG(DISTINCT c.category) filter (where c.category is not null and mc.is_additional is true) additional_categories,
|
||||||
JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,
|
JSONB_AGG(DISTINCT jsonb_build_object('id', v.id, 'date_published', v.date_published)) filter (where v.id is not null) versions,
|
||||||
@@ -864,6 +880,8 @@ impl Project {
|
|||||||
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
flame_anvil_user: m.flame_anvil_user.map(UserId),
|
||||||
webhook_sent: m.webhook_sent,
|
webhook_sent: m.webhook_sent,
|
||||||
color: m.color.map(|x| x as u32),
|
color: m.color.map(|x| x as u32),
|
||||||
|
loaders: m.loaders,
|
||||||
|
game_versions: m.game_versions,
|
||||||
},
|
},
|
||||||
project_type: m.project_type_name,
|
project_type: m.project_type_name,
|
||||||
categories: m.categories.unwrap_or_default(),
|
categories: m.categories.unwrap_or_default(),
|
||||||
@@ -904,6 +922,56 @@ impl Project {
|
|||||||
.try_collect::<Vec<QueryProject>>()
|
.try_collect::<Vec<QueryProject>>()
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn update_game_versions(
|
||||||
|
id: ProjectId,
|
||||||
|
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||||
|
) -> Result<(), sqlx::error::Error> {
|
||||||
|
sqlx::query!(
|
||||||
|
"
|
||||||
|
UPDATE mods
|
||||||
|
SET game_versions = (
|
||||||
|
SELECT COALESCE(ARRAY_AGG(DISTINCT gv.version) filter (where gv.version is not null), array[]::varchar[])
|
||||||
|
FROM versions v
|
||||||
|
INNER JOIN game_versions_versions gvv ON v.id = gvv.joining_version_id
|
||||||
|
INNER JOIN game_versions gv on gvv.game_version_id = gv.id
|
||||||
|
WHERE v.mod_id = mods.id AND v.status != ANY($2)
|
||||||
|
)
|
||||||
|
WHERE id = $1
|
||||||
|
",
|
||||||
|
id as ProjectId,
|
||||||
|
&*crate::models::projects::VersionStatus::iterator().filter(|x| x.is_hidden()).map(|x| x.to_string()).collect::<Vec<String>>()
|
||||||
|
)
|
||||||
|
.execute(&mut *transaction)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn update_loaders(
|
||||||
|
id: ProjectId,
|
||||||
|
transaction: &mut sqlx::Transaction<'_, sqlx::Postgres>,
|
||||||
|
) -> Result<(), sqlx::error::Error> {
|
||||||
|
sqlx::query!(
|
||||||
|
"
|
||||||
|
UPDATE mods
|
||||||
|
SET loaders = (
|
||||||
|
SELECT COALESCE(ARRAY_AGG(DISTINCT l.loader) filter (where l.loader is not null), array[]::varchar[])
|
||||||
|
FROM versions v
|
||||||
|
INNER JOIN loaders_versions lv ON lv.version_id = v.id
|
||||||
|
INNER JOIN loaders l on lv.loader_id = l.id
|
||||||
|
WHERE v.mod_id = mods.id AND v.status != ANY($2)
|
||||||
|
)
|
||||||
|
WHERE id = $1
|
||||||
|
",
|
||||||
|
id as ProjectId,
|
||||||
|
&*crate::models::projects::VersionStatus::iterator().filter(|x| x.is_hidden()).map(|x| x.to_string()).collect::<Vec<String>>()
|
||||||
|
)
|
||||||
|
.execute(&mut *transaction)
|
||||||
|
.await?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use super::ids::*;
|
use super::ids::*;
|
||||||
use super::DatabaseError;
|
use super::DatabaseError;
|
||||||
use crate::models::projects::{FileType, VersionStatus};
|
use crate::models::projects::{FileType, VersionStatus, VersionType};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
@@ -462,6 +462,18 @@ impl Version {
|
|||||||
)
|
)
|
||||||
.execute(&mut *transaction)
|
.execute(&mut *transaction)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
crate::database::models::Project::update_game_versions(
|
||||||
|
ProjectId(project_id.mod_id),
|
||||||
|
&mut *transaction,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
crate::database::models::Project::update_loaders(
|
||||||
|
ProjectId(project_id.mod_id),
|
||||||
|
&mut *transaction,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
|
||||||
Ok(Some(()))
|
Ok(Some(()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,6 +481,9 @@ impl Version {
|
|||||||
project_id: ProjectId,
|
project_id: ProjectId,
|
||||||
game_versions: Option<Vec<String>>,
|
game_versions: Option<Vec<String>>,
|
||||||
loaders: Option<Vec<String>>,
|
loaders: Option<Vec<String>>,
|
||||||
|
version_type: Option<VersionType>,
|
||||||
|
limit: Option<u32>,
|
||||||
|
offset: Option<u32>,
|
||||||
exec: E,
|
exec: E,
|
||||||
) -> Result<Vec<VersionId>, sqlx::Error>
|
) -> Result<Vec<VersionId>, sqlx::Error>
|
||||||
where
|
where
|
||||||
@@ -483,12 +498,16 @@ impl Version {
|
|||||||
INNER JOIN game_versions gv on gvv.game_version_id = gv.id AND (cardinality($2::varchar[]) = 0 OR gv.version = ANY($2::varchar[]))
|
INNER JOIN game_versions gv on gvv.game_version_id = gv.id AND (cardinality($2::varchar[]) = 0 OR gv.version = ANY($2::varchar[]))
|
||||||
INNER JOIN loaders_versions lv ON lv.version_id = v.id
|
INNER JOIN loaders_versions lv ON lv.version_id = v.id
|
||||||
INNER JOIN loaders l on lv.loader_id = l.id AND (cardinality($3::varchar[]) = 0 OR l.loader = ANY($3::varchar[]))
|
INNER JOIN loaders l on lv.loader_id = l.id AND (cardinality($3::varchar[]) = 0 OR l.loader = ANY($3::varchar[]))
|
||||||
WHERE v.mod_id = $1
|
WHERE v.mod_id = $1 AND ($4 = NULL OR v.version_type = $4)
|
||||||
ORDER BY v.date_published, v.id ASC
|
ORDER BY v.date_published, v.id ASC
|
||||||
|
LIMIT $5 OFFSET $6
|
||||||
",
|
",
|
||||||
project_id as ProjectId,
|
project_id as ProjectId,
|
||||||
&game_versions.unwrap_or_default(),
|
&game_versions.unwrap_or_default(),
|
||||||
&loaders.unwrap_or_default(),
|
&loaders.unwrap_or_default(),
|
||||||
|
version_type.map(|x| x.as_str()),
|
||||||
|
limit.map(|x| x as i64),
|
||||||
|
offset.map(|x| x as i64),
|
||||||
)
|
)
|
||||||
.fetch_many(exec)
|
.fetch_many(exec)
|
||||||
.try_filter_map(|e| async { Ok(e.right().map(|v| VersionId(v.version_id))) })
|
.try_filter_map(|e| async { Ok(e.right().map(|v| VersionId(v.version_id))) })
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub async fn connect() -> Result<PgPool, sqlx::Error> {
|
|||||||
.and_then(|x| x.parse().ok())
|
.and_then(|x| x.parse().ok())
|
||||||
.unwrap_or(16),
|
.unwrap_or(16),
|
||||||
)
|
)
|
||||||
.max_lifetime(Some(Duration::from_secs(60 * 60 * 6)))
|
.max_lifetime(Some(Duration::from_secs(60 * 60)))
|
||||||
.connect(&database_url)
|
.connect(&database_url)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,11 @@ pub struct Project {
|
|||||||
|
|
||||||
/// A list of the categories that the project is in.
|
/// A list of the categories that the project is in.
|
||||||
pub additional_categories: Vec<String>,
|
pub additional_categories: Vec<String>,
|
||||||
|
/// A list of game versions this project supports
|
||||||
|
pub game_versions: Vec<String>,
|
||||||
|
/// A list of loaders this project supports
|
||||||
|
pub loaders: Vec<String>,
|
||||||
|
|
||||||
/// A list of ids for versions of the project.
|
/// A list of ids for versions of the project.
|
||||||
pub versions: Vec<VersionId>,
|
pub versions: Vec<VersionId>,
|
||||||
/// The URL of the icon of the project
|
/// The URL of the icon of the project
|
||||||
@@ -154,6 +159,8 @@ impl From<QueryProject> for Project {
|
|||||||
followers: m.follows as u32,
|
followers: m.follows as u32,
|
||||||
categories: data.categories,
|
categories: data.categories,
|
||||||
additional_categories: data.additional_categories,
|
additional_categories: data.additional_categories,
|
||||||
|
game_versions: m.game_versions,
|
||||||
|
loaders: m.loaders,
|
||||||
versions: data.versions.into_iter().map(|v| v.into()).collect(),
|
versions: data.versions.into_iter().map(|v| v.into()).collect(),
|
||||||
icon_url: m.icon_url,
|
icon_url: m.icon_url,
|
||||||
issues_url: m.issues_url,
|
issues_url: m.issues_url,
|
||||||
|
|||||||
@@ -816,6 +816,8 @@ pub async fn project_create_inner(
|
|||||||
followers: 0,
|
followers: 0,
|
||||||
categories: project_create_data.categories,
|
categories: project_create_data.categories,
|
||||||
additional_categories: project_create_data.additional_categories,
|
additional_categories: project_create_data.additional_categories,
|
||||||
|
game_versions: vec![],
|
||||||
|
loaders: vec![],
|
||||||
versions: project_builder
|
versions: project_builder
|
||||||
.initial_versions
|
.initial_versions
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ pub async fn forge_updates(
|
|||||||
project.id,
|
project.id,
|
||||||
None,
|
None,
|
||||||
Some(vec!["forge".to_string()]),
|
Some(vec!["forge".to_string()]),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
&**pool,
|
&**pool,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ pub async fn projects_list(
|
|||||||
crate::database::Project::get_many_full(&project_data, &**pool)
|
crate::database::Project::get_many_full(&project_data, &**pool)
|
||||||
.await?
|
.await?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|x| can_view_private || x.inner.status.is_approved())
|
.filter(|x| can_view_private || x.inner.status.is_searchable())
|
||||||
.map(Project::from)
|
.map(Project::from)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,9 @@ pub async fn version_list(
|
|||||||
.loaders
|
.loaders
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|x| serde_json::from_str(x).unwrap_or_default()),
|
.map(|x| serde_json::from_str(x).unwrap_or_default()),
|
||||||
|
filters.version_type,
|
||||||
|
filters.limit,
|
||||||
|
filters.offset,
|
||||||
&**pool,
|
&**pool,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -422,6 +422,14 @@ async fn version_create_inner(
|
|||||||
.insert_many(users, &mut *transaction)
|
.insert_many(users, &mut *transaction)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
models::Project::update_game_versions(
|
||||||
|
builder.project_id,
|
||||||
|
&mut *transaction,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
models::Project::update_loaders(builder.project_id, &mut *transaction)
|
||||||
|
.await?;
|
||||||
|
|
||||||
let response = Version {
|
let response = Version {
|
||||||
id: builder.version_id.into(),
|
id: builder.version_id.into(),
|
||||||
project_id: builder.project_id.into(),
|
project_id: builder.project_id.into(),
|
||||||
|
|||||||
@@ -301,6 +301,9 @@ pub async fn get_update_from_hash(
|
|||||||
.map(|x| x.0)
|
.map(|x| x.0)
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
&**pool,
|
&**pool,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -493,6 +496,9 @@ pub async fn update_files(
|
|||||||
.map(|x| x.0.clone())
|
.map(|x| x.0.clone())
|
||||||
.collect(),
|
.collect(),
|
||||||
),
|
),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
&**pool,
|
&**pool,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
use super::ApiError;
|
use super::ApiError;
|
||||||
use crate::database;
|
use crate::database;
|
||||||
use crate::models;
|
use crate::models;
|
||||||
use crate::models::projects::{Dependency, FileType, Version, VersionStatus};
|
use crate::models::projects::{
|
||||||
|
Dependency, FileType, Version, VersionStatus, VersionType,
|
||||||
|
};
|
||||||
use crate::models::teams::Permissions;
|
use crate::models::teams::Permissions;
|
||||||
use crate::util::auth::{
|
use crate::util::auth::{
|
||||||
get_user_from_headers, is_authorized, is_authorized_version,
|
get_user_from_headers, is_authorized, is_authorized_version,
|
||||||
@@ -19,6 +21,9 @@ pub struct VersionListFilters {
|
|||||||
pub game_versions: Option<String>,
|
pub game_versions: Option<String>,
|
||||||
pub loaders: Option<String>,
|
pub loaders: Option<String>,
|
||||||
pub featured: Option<bool>,
|
pub featured: Option<bool>,
|
||||||
|
pub version_type: Option<VersionType>,
|
||||||
|
pub limit: Option<u32>,
|
||||||
|
pub offset: Option<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("version")]
|
#[get("version")]
|
||||||
@@ -54,6 +59,9 @@ pub async fn version_list(
|
|||||||
.loaders
|
.loaders
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|x| serde_json::from_str(x).unwrap_or_default()),
|
.map(|x| serde_json::from_str(x).unwrap_or_default()),
|
||||||
|
filters.version_type,
|
||||||
|
filters.limit,
|
||||||
|
filters.offset,
|
||||||
&**pool,
|
&**pool,
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@@ -393,6 +401,12 @@ pub async fn version_edit(
|
|||||||
.execute(&mut *transaction)
|
.execute(&mut *transaction)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
database::models::Project::update_game_versions(
|
||||||
|
version_item.inner.project_id,
|
||||||
|
&mut transaction,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(loaders) = &new_version.loaders {
|
if let Some(loaders) = &new_version.loaders {
|
||||||
@@ -430,6 +444,12 @@ pub async fn version_edit(
|
|||||||
.execute(&mut *transaction)
|
.execute(&mut *transaction)
|
||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
database::models::Project::update_loaders(
|
||||||
|
version_item.inner.project_id,
|
||||||
|
&mut transaction,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(featured) = &new_version.featured {
|
if let Some(featured) = &new_version.featured {
|
||||||
|
|||||||
Reference in New Issue
Block a user