Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
Fixes search not reading sidetypes (#823)
Browse files Browse the repository at this point in the history
  • Loading branch information
thesuzerain authored Jan 6, 2024
1 parent 917b89e commit 5275213
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ ARG SQLX_OFFLINE=true
RUN cargo build --release


FROM debian:bullseye-slim
# Final Stage
FROM ubuntu:latest

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates \
Expand Down
21 changes: 3 additions & 18 deletions src/search/indexing/local_import.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use std::collections::HashMap;
use std::sync::Arc;

use dashmap::DashSet;
use futures::TryStreamExt;
use log::info;
use std::collections::HashMap;

use super::IndexingError;
use crate::database::models::{project_item, version_item, ProjectId, VersionId};
Expand Down Expand Up @@ -54,10 +51,8 @@ pub async fn index_local(
pool: &PgPool,
redis: &RedisPool,
visible_ids: HashMap<VersionId, (ProjectId, String)>,
) -> Result<(Vec<UploadSearchProject>, Vec<String>), IndexingError> {
) -> Result<Vec<UploadSearchProject>, IndexingError> {
info!("Indexing local projects!");
let loader_field_keys: Arc<DashSet<String>> = Arc::new(DashSet::new());

let project_ids = visible_ids
.values()
.map(|(project_id, _)| project_id)
Expand Down Expand Up @@ -120,10 +115,6 @@ pub async fn index_local(

let version_fields = v.version_fields.clone();
let loader_fields = models::projects::from_duplicate_version_fields(version_fields);
for v in loader_fields.keys().cloned() {
loader_field_keys.insert(v);
}

let license = match m.inner.license.split(' ').next() {
Some(license) => license.to_string(),
None => m.inner.license.clone(),
Expand Down Expand Up @@ -223,11 +214,5 @@ pub async fn index_local(
uploads.push(usp);
}

Ok((
uploads,
Arc::try_unwrap(loader_field_keys)
.unwrap_or_default()
.into_iter()
.collect(),
))
Ok(uploads)
}
11 changes: 9 additions & 2 deletions src/search/indexing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ pub async fn index_projects(

let indices = get_indexes(config).await?;

let all_loader_fields =
crate::database::models::loader_fields::LoaderField::get_fields_all(&pool, &redis)
.await?
.into_iter()
.map(|x| x.field)
.collect::<Vec<_>>();

let all_ids = get_all_ids(pool.clone()).await?;
let all_ids_len = all_ids.len();
info!("Got all ids, indexing {} projects", all_ids_len);
Expand Down Expand Up @@ -93,10 +100,10 @@ pub async fn index_projects(
(version_id, (project_id, owner_username.to_lowercase()))
})
.collect::<HashMap<_, _>>();
let (uploads, loader_fields) = index_local(&pool, &redis, id_chunk).await?;
let uploads = index_local(&pool, &redis, id_chunk).await?;

info!("Got chunk, adding to docs_to_add");
add_projects(&indices, uploads, loader_fields, config).await?;
add_projects(&indices, uploads, all_loader_fields.clone(), config).await?;
}

info!("Done adding projects.");
Expand Down

0 comments on commit 5275213

Please sign in to comment.