You've already forked AstralRinth
forked from didirus/AstralRinth
Optimize and fix some bugs in indexing (#98)
* Improve curseforge and local indexing This should make curseforge indexing more efficient, and reuses some of the normal local indexing for the queued indexing of recently created mods. * Unify impls for single and multiple routes for mods and versions This uses the same backend for the single and multiple query routes so that they no longer return inconsistent information. * Cache valid curseforge mod ids to reduce request load This caches the ids of minecraft mods and reuses them on indexing to reduce the amount of unused addons that are returned.
This commit is contained in:
@@ -312,15 +312,38 @@ impl Mod {
|
||||
.try_collect::<Vec<VersionId>>()
|
||||
.await?;
|
||||
|
||||
let status = sqlx::query!(
|
||||
"
|
||||
SELECT status FROM statuses
|
||||
WHERE id = $1
|
||||
",
|
||||
inner.status.0,
|
||||
)
|
||||
.fetch_one(executor)
|
||||
.await?
|
||||
.status;
|
||||
|
||||
Ok(Some(QueryMod {
|
||||
inner,
|
||||
categories,
|
||||
versions,
|
||||
status: crate::models::mods::ModStatus::from_str(&status),
|
||||
}))
|
||||
} else {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_many_full<'a, E>(
|
||||
mod_ids: Vec<ModId>,
|
||||
exec: E,
|
||||
) -> Result<Vec<Option<QueryMod>>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
// TODO: this could be optimized
|
||||
futures::future::try_join_all(mod_ids.into_iter().map(|id| Self::get_full(id, exec))).await
|
||||
}
|
||||
}
|
||||
|
||||
pub struct QueryMod {
|
||||
@@ -328,4 +351,5 @@ pub struct QueryMod {
|
||||
|
||||
pub categories: Vec<String>,
|
||||
pub versions: Vec<VersionId>,
|
||||
pub status: crate::models::mods::ModStatus,
|
||||
}
|
||||
|
||||
@@ -523,6 +523,18 @@ impl Version {
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_many_full<'a, E>(
|
||||
version_ids: Vec<VersionId>,
|
||||
exec: E,
|
||||
) -> Result<Vec<Option<QueryVersion>>, sqlx::Error>
|
||||
where
|
||||
E: sqlx::Executor<'a, Database = sqlx::Postgres> + Copy,
|
||||
{
|
||||
// TODO: this could be optimized
|
||||
futures::future::try_join_all(version_ids.into_iter().map(|id| Self::get_full(id, exec)))
|
||||
.await
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ReleaseChannel {
|
||||
|
||||
Reference in New Issue
Block a user