feat(labrinth): Add support for dependencies in search#5385
feat(labrinth): Add support for dependencies in search#5385IThundxr wants to merge 10 commits intomodrinth:mainfrom
Conversation
Prospector
left a comment
There was a problem hiding this comment.
I would add each dependency type as a separate array, so like required_dependencies, optional_dependencies, incompatibilities, etc.
Went ahead and made it use a map instead, the output of |
|
Actually, you wouldn't be able to filter those with facets, i'll split them into 3 different arrays |
# Conflicts: # apps/labrinth/src/search/backend/meilisearch/indexing.rs # apps/labrinth/src/search/indexing.rs
fetchfern
left a comment
There was a problem hiding this comment.
Would need to be migrated to typesense since we use it for search now
| let records = sqlx::query!( | ||
| " | ||
| SELECT d.mod_dependency_id as \"mod_dependency_id: DBProjectId\", d.dependency_type, m.slug as \"slug\" FROM dependencies d | ||
| INNER JOIN mods m ON m.id = d.mod_dependency_id | ||
| WHERE dependent_id = $1", | ||
| version_id.0 | ||
| ) | ||
| .fetch_all(pool) | ||
| .await?; |
There was a problem hiding this comment.
This query should be batched like the queries above it instead of running for every single version.
This doesn't account for version dependencies.
Would exclude embedded dependencies, at least for now, since it could drastically increase document size for modpacks which might have performance implications.
| if let Some(id) = r.mod_dependency_id { | ||
| v.push(crate::models::ids::ProjectId::from(id).to_string()) | ||
| } | ||
|
|
||
| if let Some(slug) = &r.slug { | ||
| v.push(slug.to_string()) | ||
| } |
There was a problem hiding this comment.
I don't love including both the slug and project ID, would include only the ID.
The item type should be something like below instead of an either-id-or-slug string:
struct Dependency {
#[serde(default, skip_serializing_if = "Option::is_none")]
version: Option<Id>,
project: Id,
}
| pub required_dependencies: Vec<String>, | ||
| pub optional_dependencies: Vec<String>, | ||
| pub embedded_dependencies: Vec<String>, | ||
| pub incompatibilities: Vec<String>, |
There was a problem hiding this comment.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
| pub required_dependencies: Vec<String>, | ||
| pub optional_dependencies: Vec<String>, | ||
| pub embedded_dependencies: Vec<String>, | ||
| pub incompatibilities: Vec<String>, |
There was a problem hiding this comment.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
Adds dependencies to the projects index in meilisearch, this will allow you to search for mods depending on a specific mod. This is a continuation of #4105.
This currently does not include support for searching dependencies in the frontend, some work has been done here but i'm not entirely sure how this should be laid out and look like, i think it'll be better for the team to work on implementing that instead.