Featured filtering patch (#825)

This commit is contained in:
Wyatt Verchere
2024-01-06 19:31:34 -08:00
committed by GitHub
parent 527521328f
commit 541022cdc3
5 changed files with 94 additions and 52 deletions

View File

@@ -293,26 +293,27 @@ async fn update_and_add_to_index(
client: &Client,
index: &Index,
projects: &[UploadSearchProject],
additional_fields: &[String],
_additional_fields: &[String],
) -> Result<(), IndexingError> {
let mut new_filterable_attributes: Vec<String> = index.get_filterable_attributes().await?;
let mut new_displayed_attributes = index.get_displayed_attributes().await?;
// TODO: Uncomment this- hardcoding loader_fields is a band-aid fix, and will be fixed soon
// let mut new_filterable_attributes: Vec<String> = index.get_filterable_attributes().await?;
// let mut new_displayed_attributes = index.get_displayed_attributes().await?;
new_filterable_attributes.extend(additional_fields.iter().map(|s| s.to_string()));
new_displayed_attributes.extend(additional_fields.iter().map(|s| s.to_string()));
info!("add attributes.");
let filterable_task = index
.set_filterable_attributes(new_filterable_attributes)
.await?;
let displayable_task = index
.set_displayed_attributes(new_displayed_attributes)
.await?;
filterable_task
.wait_for_completion(client, None, Some(TIMEOUT))
.await?;
displayable_task
.wait_for_completion(client, None, Some(TIMEOUT))
.await?;
// new_filterable_attributes.extend(additional_fields.iter().map(|s: &String| s.to_string()));
// new_displayed_attributes.extend(additional_fields.iter().map(|s| s.to_string()));
// info!("add attributes.");
// let filterable_task = index
// .set_filterable_attributes(new_filterable_attributes)
// .await?;
// let displayable_task = index
// .set_displayed_attributes(new_displayed_attributes)
// .await?;
// filterable_task
// .wait_for_completion(client, None, Some(TIMEOUT))
// .await?;
// displayable_task
// .wait_for_completion(client, None, Some(TIMEOUT))
// .await?;
info!("Adding to index.");
@@ -374,7 +375,13 @@ const DEFAULT_DISPLAYED_ATTRIBUTES: &[&str] = &[
"featured_gallery",
"color",
// 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.
"server_only",
"client_only",
"game_versions",
"singleplayer",
"client_and_server",
"mrpack_loaders",
// Non-searchable fields for filling out the Project model.
"license_url",
"monetization_status",
@@ -409,6 +416,14 @@ const DEFAULT_ATTRIBUTES_FOR_FACETING: &[&str] = &[
"project_id",
"open_source",
"color",
// 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.
"server_only",
"client_only",
"game_versions",
"singleplayer",
"client_and_server",
"mrpack_loaders",
];
const DEFAULT_SORTABLE_ATTRIBUTES: &[&str] =