Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

This file was deleted.

28 changes: 28 additions & 0 deletions apps/labrinth/src/search/indexing/local_import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ pub async fn index_local(
featured_gallery: featured_gallery.clone(),
open_source,
color: project.color.map(|x| x as u32),
dependencies: version.dependencies,
loader_fields,
project_loader_fields: project_loader_fields.clone(),
// 'loaders' is aggregate of all versions' loaders
Expand All @@ -433,6 +434,7 @@ struct PartialVersion {
loaders: Vec<String>,
project_types: Vec<String>,
version_fields: Vec<QueryVersionField>,
dependencies: Vec<String>,
}

async fn index_versions(
Expand Down Expand Up @@ -549,6 +551,31 @@ async fn index_versions(
.map(|(_, version_fields)| version_fields)
.unwrap_or_default();

let dependencies: Vec<String> = sqlx::query!(
"
SELECT d.mod_dependency_id as \"mod_dependency_id: DBProjectId\", 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?
.iter()
.flat_map(|r| {
let mut v = Vec::new();

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())
}

v
})
.collect();

res_versions
.entry(*project_id)
.or_default()
Expand All @@ -557,6 +584,7 @@ async fn index_versions(
loaders: version_loader_data.loaders,
project_types: version_loader_data.project_types,
version_fields,
dependencies,
});
}
}
Expand Down
2 changes: 2 additions & 0 deletions apps/labrinth/src/search/indexing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ const DEFAULT_DISPLAYED_ATTRIBUTES: &[&str] = &[
"gallery",
"featured_gallery",
"color",
"dependencies",
// Note: loader fields are not here, but are added on as they are needed (so they can be dynamically added depending on which exist).
// TODO: remove these- as they should be automatically populated. This is a band-aid fix.
"environment",
Expand Down Expand Up @@ -609,6 +610,7 @@ const DEFAULT_ATTRIBUTES_FOR_FACETING: &[&str] = &[
"project_id",
"open_source",
"color",
"dependencies",
// Note: loader fields are not here, but are added on as they are needed (so they can be dynamically added depending on which exist).
// TODO: remove these- as they should be automatically populated. This is a band-aid fix.
"environment",
Expand Down
4 changes: 4 additions & 0 deletions apps/labrinth/src/search/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ pub struct UploadSearchProject {
pub open_source: bool,
pub color: Option<u32>,

pub dependencies: Vec<String>,

// Hidden fields to get the Project model out of the search results.
pub loaders: Vec<String>, // Search uses loaders as categories- this is purely for the Project model.
pub project_loader_fields: HashMap<String, Vec<serde_json::Value>>, // Aggregation of loader_fields from all versions of the project, allowing for reconstruction of the Project model.
Expand Down Expand Up @@ -255,6 +257,8 @@ pub struct ResultSearchProject {
pub featured_gallery: Option<String>,
pub color: Option<u32>,

pub dependencies: Vec<String>,

// Hidden fields to get the Project model out of the search results.
pub loaders: Vec<String>, // Search uses loaders as categories- this is purely for the Project model.
pub project_loader_fields: HashMap<String, Vec<serde_json::Value>>, // Aggregation of loader_fields from all versions of the project, allowing for reconstruction of the Project model.
Expand Down