Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

chore(search): remove projects from opensearch (#909)

Will Hutchinson1969f70f7d2e
diff --git a/infra/stacks/opensearch/helpers/bun.lock b/infra/stacks/opensearch/helpers/bun.lock
index 35dd3b9274..ebaa6e1791 100644
--- a/infra/stacks/opensearch/helpers/bun.lock
+++ b/infra/stacks/opensearch/helpers/bun.lock
@@ -1,5 +1,6 @@
{
"lockfileVersion": 1,
+ "configVersion": 0,
"workspaces": {
"": {
"name": "opensearch-test",
diff --git a/infra/stacks/opensearch/helpers/constants.ts b/infra/stacks/opensearch/helpers/constants.ts
index 460fa7658c..9ce4665673 100644
--- a/infra/stacks/opensearch/helpers/constants.ts
+++ b/infra/stacks/opensearch/helpers/constants.ts
@@ -2,17 +2,9 @@ const CHAT_INDEX = 'chats';
const DOCUMENT_INDEX = 'documents';
const EMAIL_INDEX = 'emails';
const CHANNEL_INDEX = 'channels';
-const PROJECT_INDEX = 'projects';
const NAMES_INDEX = 'names';
-export {
- CHAT_INDEX,
- DOCUMENT_INDEX,
- EMAIL_INDEX,
- CHANNEL_INDEX,
- PROJECT_INDEX,
- NAMES_INDEX,
-};
+export { CHAT_INDEX, DOCUMENT_INDEX, EMAIL_INDEX, CHANNEL_INDEX, NAMES_INDEX };
export const SHARD_SETTINGS =
process.env.ENVIRONMENT === 'prod'
diff --git a/infra/stacks/opensearch/helpers/scripts/copy_entity_id.ts b/infra/stacks/opensearch/helpers/scripts/copy_entity_id.ts
index ca45273b61..4aa874859c 100644
--- a/infra/stacks/opensearch/helpers/scripts/copy_entity_id.ts
+++ b/infra/stacks/opensearch/helpers/scripts/copy_entity_id.ts
@@ -9,7 +9,6 @@ import {
DOCUMENT_INDEX,
EMAIL_INDEX,
IS_DRY_RUN,
- PROJECT_INDEX,
} from '../constants';
import type { IndexMigration } from '../utils/migrate_field';
import { migrateIndex } from '../utils/migrate_field';
@@ -33,10 +32,6 @@ const MIGRATIONS: IndexMigration[] = [
indexName: EMAIL_INDEX,
fields: [{ oldField: 'thread_id', newField: ENTITY_ID_FIELD }],
},
- {
- indexName: PROJECT_INDEX,
- fields: [{ oldField: 'project_id', newField: ENTITY_ID_FIELD }],
- },
];
async function run(dryRun: boolean = true) {
diff --git a/infra/stacks/opensearch/helpers/scripts/copy_timestamp_data.ts b/infra/stacks/opensearch/helpers/scripts/copy_timestamp_data.ts
index 396f179272..1e00810310 100644
--- a/infra/stacks/opensearch/helpers/scripts/copy_timestamp_data.ts
+++ b/infra/stacks/opensearch/helpers/scripts/copy_timestamp_data.ts
@@ -6,7 +6,6 @@ import {
CHAT_INDEX,
DOCUMENT_INDEX,
EMAIL_INDEX,
- PROJECT_INDEX,
} from '../constants';
import { type IndexMigration, migrateIndex } from '../utils/migrate_field';
@@ -33,13 +32,6 @@ const MIGRATIONS: IndexMigration[] = [
{ oldField: 'sent_at', newField: 'sent_at_seconds' },
],
},
- {
- indexName: PROJECT_INDEX,
- fields: [
- { oldField: 'created_at', newField: 'created_at_seconds' },
- { oldField: 'updated_at', newField: 'updated_at_seconds' },
- ],
- },
];
async function copyData(dryRun: boolean = true) {
diff --git a/infra/stacks/opensearch/helpers/scripts/create_entity_id.ts b/infra/stacks/opensearch/helpers/scripts/create_entity_id.ts
index c3582f5c52..e6c9792995 100644
--- a/infra/stacks/opensearch/helpers/scripts/create_entity_id.ts
+++ b/infra/stacks/opensearch/helpers/scripts/create_entity_id.ts
@@ -9,7 +9,6 @@ import {
DOCUMENT_INDEX,
EMAIL_INDEX,
IS_DRY_RUN,
- PROJECT_INDEX,
} from '../constants';
import { addFieldToIndex } from '../utils/add_field';
import { checkIndexExists } from '../utils/check_index_exists';
@@ -22,7 +21,6 @@ const MIGRATIONS: string[] = [
CHAT_INDEX,
DOCUMENT_INDEX,
EMAIL_INDEX,
- PROJECT_INDEX,
];
async function run(dryRun: boolean = true) {
diff --git a/infra/stacks/opensearch/helpers/scripts/create_indices.ts b/infra/stacks/opensearch/helpers/scripts/create_indices.ts
index aba9728412..359df77f83 100644
--- a/infra/stacks/opensearch/helpers/scripts/create_indices.ts
+++ b/infra/stacks/opensearch/helpers/scripts/create_indices.ts
@@ -6,7 +6,6 @@ import {
DOCUMENT_INDEX,
EMAIL_INDEX,
NAMES_INDEX,
- PROJECT_INDEX,
SHARD_SETTINGS,
} from '../constants';
@@ -367,68 +366,6 @@ async function createEmailIndex(opensearchClient: Client) {
}
}
-async function createProjectIndex(opensearchClient: Client) {
- const projectIndexExists = (
- await opensearchClient.indices.exists({
- index: PROJECT_INDEX,
- })
- ).body;
- if (!projectIndexExists) {
- console.log(`${PROJECT_INDEX} index does not exist, creating...`);
-
- opensearchClient.indices.create({
- index: PROJECT_INDEX,
- body: {
- settings: {
- ...SHARD_SETTINGS,
- refresh_interval: '1s', // Default is 1s
- },
- mappings: {
- properties: {
- // The project id
- entity_id: {
- type: 'keyword',
- },
- user_id: {
- type: 'keyword',
- index: true,
- doc_values: true,
- },
- parent_project_id: {
- type: 'keyword',
- index: true,
- doc_values: true,
- },
- project_name: {
- type: 'text',
- fields: {
- keyword: {
- type: 'keyword',
- ignore_above: 128,
- },
- },
- },
- updated_at_seconds: {
- type: 'date',
- format: 'epoch_second',
- index: false,
- doc_values: true,
- },
- created_at_seconds: {
- type: 'date',
- format: 'epoch_second',
- index: false,
- doc_values: true,
- },
- },
- },
- },
- });
- } else {
- console.log(`${PROJECT_INDEX} index already exists`);
- }
-}
-
async function createIndices() {
const opensearchClient = client();
console.log('Creating indices...');
@@ -438,7 +375,6 @@ async function createIndices() {
await createChatIndex(opensearchClient);
await createEmailIndex(opensearchClient);
await createChannelIndex(opensearchClient);
- await createProjectIndex(opensearchClient);
await createNamesIndex(opensearchClient);
console.log('done');
} catch (error) {
diff --git a/infra/stacks/opensearch/helpers/scripts/create_timestamp_seconds_fields.ts b/infra/stacks/opensearch/helpers/scripts/create_timestamp_seconds_fields.ts
index 1013ab2883..db41e88937 100644
--- a/infra/stacks/opensearch/helpers/scripts/create_timestamp_seconds_fields.ts
+++ b/infra/stacks/opensearch/helpers/scripts/create_timestamp_seconds_fields.ts
@@ -7,7 +7,6 @@ import {
CHAT_INDEX,
DOCUMENT_INDEX,
EMAIL_INDEX,
- PROJECT_INDEX,
} from '../constants';
interface DateField {
@@ -42,13 +41,6 @@ const MIGRATIONS: IndexMigration[] = [
{ fieldName: 'sent_at_seconds' },
],
},
- {
- indexName: PROJECT_INDEX,
- dateFields: [
- { fieldName: 'created_at_seconds' },
- { fieldName: 'updated_at_seconds' },
- ],
- },
];
async function addDateFieldWithEpochSecondFormat(
diff --git a/infra/stacks/opensearch/helpers/scripts/remove_epoch_millis_date_mappings.ts b/infra/stacks/opensearch/helpers/scripts/remove_epoch_millis_date_mappings.ts
index 1eb7e09c1d..64bed8a706 100644
--- a/infra/stacks/opensearch/helpers/scripts/remove_epoch_millis_date_mappings.ts
+++ b/infra/stacks/opensearch/helpers/scripts/remove_epoch_millis_date_mappings.ts
@@ -7,7 +7,6 @@ import {
DOCUMENT_INDEX,
EMAIL_INDEX,
IS_DRY_RUN,
- PROJECT_INDEX,
} from '../constants';
import { removeField } from '../utils/remove_field';
@@ -37,10 +36,6 @@ const CLEANUPS: IndexCleanup[] = [
indexName: EMAIL_INDEX,
fieldsToRemove: [{ fieldName: 'updated_at' }, { fieldName: 'sent_at' }],
},
- {
- indexName: PROJECT_INDEX,
- fieldsToRemove: [{ fieldName: 'created_at' }, { fieldName: 'updated_at' }],
- },
];
async function run(dryRun: boolean = true) {
diff --git a/infra/stacks/opensearch/helpers/scripts/remove_legacy_id.ts b/infra/stacks/opensearch/helpers/scripts/remove_legacy_id.ts
index 0b0bb18828..b908f36f66 100644
--- a/infra/stacks/opensearch/helpers/scripts/remove_legacy_id.ts
+++ b/infra/stacks/opensearch/helpers/scripts/remove_legacy_id.ts
@@ -7,7 +7,6 @@ import {
DOCUMENT_INDEX,
EMAIL_INDEX,
IS_DRY_RUN,
- PROJECT_INDEX,
} from '../constants';
import { removeField } from '../utils/remove_field';
@@ -33,10 +32,6 @@ const CLEANUPS: IndexCleanup[] = [
indexName: EMAIL_INDEX,
legacyIdField: 'thread_id',
},
- {
- indexName: PROJECT_INDEX,
- legacyIdField: 'project_id',
- },
];
async function run(dryRun: boolean = true) {
diff --git a/infra/stacks/opensearch/helpers/scripts/set_refresh_interval.ts b/infra/stacks/opensearch/helpers/scripts/set_refresh_interval.ts
index fec98193ec..82615ee8f2 100644
--- a/infra/stacks/opensearch/helpers/scripts/set_refresh_interval.ts
+++ b/infra/stacks/opensearch/helpers/scripts/set_refresh_interval.ts
@@ -5,7 +5,6 @@ import {
CHAT_INDEX,
DOCUMENT_INDEX,
EMAIL_INDEX,
- PROJECT_INDEX,
} from '../constants';
interface RefreshConfig {
@@ -18,7 +17,6 @@ const REFRESH_INTERVALS: RefreshConfig = {
[CHANNEL_INDEX]: '1s',
[EMAIL_INDEX]: '2s',
[DOCUMENT_INDEX]: '1s',
- [PROJECT_INDEX]: '1s',
};
async function updateIndexRefreshInterval(
diff --git a/rust/cloud-storage/deleted_item_poller/src/handler.rs b/rust/cloud-storage/deleted_item_poller/src/handler.rs
index cfde6e1061..6cce3b8e4a 100644
--- a/rust/cloud-storage/deleted_item_poller/src/handler.rs
+++ b/rust/cloud-storage/deleted_item_poller/src/handler.rs
@@ -5,9 +5,7 @@ use lambda_runtime::{
Error, LambdaEvent,
tracing::{self},
};
-use sqs_client::search::{
- SearchQueueMessage, chat::RemoveChatMessage, document::DocumentId, project,
-};
+use sqs_client::search::{SearchQueueMessage, chat::RemoveChatMessage, document::DocumentId};
#[tracing::instrument(skip(ctx, _event), err)]
pub async fn handler(
@@ -43,15 +41,6 @@ async fn handle_projects(ctx: &context::Context) -> anyhow::Result<()> {
.await
.context("unable to delete projects")?;
- let _ = ctx
- .sqs_client
- .send_message_to_search_event_queue(SearchQueueMessage::BulkRemoveProjectMessage(
- project::BulkRemoveProjectMessage {
- project_ids: projects_to_delete,
- },
- ))
- .await?;
-
Ok(())
}
diff --git a/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs b/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs
index 9281bfcfba..1e45f76987 100644
--- a/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/projects/create_project.rs
@@ -12,8 +12,6 @@ use model::{
};
use models_permissions::share_permission::SharePermissionV2;
use models_permissions::share_permission::access_level::EditAccessLevel;
-use sqs_client::search::{SearchQueueMessage, project};
-use tracing::Instrument;
/// Creates a new project.
/// The project can be created as a sub-project of another project or as a top-level project.
@@ -94,27 +92,5 @@ async fn create_project_v2(
.await;
}
- // Add project to search index
- tokio::spawn({
- let sqs_client = ctx.sqs_client.clone();
- let project_id = project.id.clone();
- let macro_user_id = user_context.user_context.user_id.clone();
- async move {
- tracing::trace!("sending message to search extractor queue");
- let _ = sqs_client
- .send_message_to_search_event_queue(SearchQueueMessage::ProjectMessage(
- project::ProjectMessage {
- project_id,
- macro_user_id,
- },
- ))
- .await
- .inspect_err(|e| {
- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");
- });
- }
- .in_current_span()
- });
-
Ok(project)
}
diff --git a/rust/cloud-storage/document_storage_service/src/api/projects/delete_project.rs b/rust/cloud-storage/document_storage_service/src/api/projects/delete_project.rs
index b2b57a9327..30c2e41969 100644
--- a/rust/cloud-storage/document_storage_service/src/api/projects/delete_project.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/projects/delete_project.rs
@@ -16,10 +16,7 @@ use model::{
user::UserContext,
};
use models_permissions::share_permission::access_level::OwnerAccessLevel;
-use sqs_client::search::{
- SearchQueueMessage, chat::RemoveChatMessage, document::DocumentId, project,
-};
-use tracing::Instrument;
+use sqs_client::search::{SearchQueueMessage, chat::RemoveChatMessage, document::DocumentId};
use utoipa::ToSchema;
#[derive(serde::Deserialize)]
@@ -316,26 +313,6 @@ pub async fn permanently_delete_project_handler(
let response_data = GenericSuccessResponse { success: true };
- // delete projects from search
- // NOTE: project_ids should contain the root project in addition
- // to the other projects, so the deletion can be done in one call
- tokio::spawn({
- let sqs_client = ctx.sqs_client.clone();
- let project_ids = project_ids.clone();
- async move {
- tracing::trace!("sending message to search extractor queue");
- let _ = sqs_client
- .send_message_to_search_event_queue(SearchQueueMessage::BulkRemoveProjectMessage(
- project::BulkRemoveProjectMessage { project_ids },
- ))
- .await
- .inspect_err(|e| {
- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");
- });
- }
- .in_current_span()
- });
-
Ok(GenericResponse::builder()
.data(&response_data)
.send(StatusCode::OK))
diff --git a/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs b/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs
index bfffa25747..20c36e1ce3 100644
--- a/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs
+++ b/rust/cloud-storage/document_storage_service/src/api/projects/edit_project.rs
@@ -14,8 +14,6 @@ use model::response::{GenericErrorResponse, SuccessResponse};
use model::{project::BasicProject, response::GenericSuccessResponse};
use model::{project::request::PatchProjectRequestV2, response::ErrorResponse, user::UserContext};
use models_permissions::share_permission::access_level::{AccessLevel, EditAccessLevel};
-use sqs_client::search::{SearchQueueMessage, project};
-use tracing::Instrument;
#[derive(serde::Deserialize)]
pub struct Params {
@@ -191,30 +189,6 @@ async fn edit_project_v2(
)
.await;
- // Update search index if name changes
- if req.name.is_some() {
- tokio::spawn({
- let sqs_client = ctx.sqs_client.clone();
- let project_id = id.clone();
- let macro_user_id = user_context.user_id.clone();
- async move {
- tracing::trace!("sending message to search extractor queue");
- let _ = sqs_client
- .send_message_to_search_event_queue(SearchQueueMessage::ProjectMessage(
- project::ProjectMessage {
- project_id,
- macro_user_id,
- },
- ))
- .await
- .inspect_err(|e| {
- tracing::error!(error=?e, "SEARCH_QUEUE unable to enqueue message");
- });
- }
- .in_current_span()
- });
- }
-
Ok(())
}
diff --git a/rust/cloud-storage/opensearch_client/src/delete/mod.rs b/rust/cloud-storage/opensearch_client/src/delete/mod.rs
index 82ce8db5c7..fd69901855 100644
--- a/rust/cloud-storage/opensearch_client/src/delete/mod.rs
+++ b/rust/cloud-storage/opensearch_client/src/delete/mod.rs
@@ -3,4 +3,3 @@ pub mod chat;
pub mod document;
pub mod email;
pub mod name;
-pub mod project;
diff --git a/rust/cloud-storage/opensearch_client/src/delete/project.rs b/rust/cloud-storage/opensearch_client/src/delete/project.rs
deleted file mode 100644
index 6ead3e4c59..0000000000
--- a/rust/cloud-storage/opensearch_client/src/delete/project.rs
+++ /dev/null
@@ -1,168 +0,0 @@
-use models_opensearch::SearchIndex;
-
-use crate::{Result, error::OpensearchClientError};
-
-/// Deletes a project by its ID
-#[tracing::instrument(skip(client))]
-pub async fn delete_project_by_id(client: &opensearch::OpenSearch, project_id: &str) -> Result<()> {
- let response = client
- .delete(opensearch::DeleteParts::IndexId(
- SearchIndex::Projects.as_ref(),
- project_id,
- ))
- .refresh(opensearch::params::Refresh::True) // Ensure the index reflects changes immediately
- .send()
- .await
- .map_err(|err| OpensearchClientError::Unknown {
- details: err.to_string(),
- method: Some("delete_project_by_id".to_string()),
- })?;
-
- let status_code = response.status_code();
-
- if !status_code.is_success() {
- let body =
- response
- .text()
- .await
- .map_err(|err| OpensearchClientError::DeserializationFailed {
- details: err.to_string(),
- method: Some("delete_project_by_id".to_string()),
- })?;
-
- tracing::error!(
- status_code = ?status_code,
- body = ?body,
- project_id = %project_id,
- "error deleting project by id"
- );
-
- return Err(OpensearchClientError::Unknown {
- details: body,
- method: Some("delete_project_by_id".to_string()),
- });
- }
-
- tracing::trace!(project_id = %project_id, "project deleted successfully");
- Ok(())
-}
-
-/// Deletes multiple projects by their IDs
-#[tracing::instrument(skip(client))]
-pub async fn delete_project_bulk_ids(
- client: &opensearch::OpenSearch,
- project_ids: &Vec<String>,
-) -> Result<()> {
- if project_ids.is_empty() {
- return Ok(());
- }
-
- let formatted_ids: Vec<String> = project_ids
- .iter()
- .map(|id| format!("{}:{}", id, id))
- .collect();
-
- let query = serde_json::json!({
- "query": {
- "terms": {
- "_id": formatted_ids
- }
- }
- });
-
- let response = client
- .delete_by_query(opensearch::DeleteByQueryParts::Index(&[
- SearchIndex::Projects.as_ref(),
- ]))
- .body(query)
- .refresh(true)
- .send()
- .await
- .map_err(|err| OpensearchClientError::Unknown {
- details: err.to_string(),
- method: Some("delete_project_bulk_ids".to_string()),
- })?;
-
- let status_code = response.status_code();
-
- if !status_code.is_success() {
- let body =
- response
- .text()
- .await
- .map_err(|err| OpensearchClientError::DeserializationFailed {
- details: err.to_string(),
- method: Some("delete_project_bulk_ids".to_string()),
- })?;
-
- tracing::error!(
- status_code = ?status_code,
- body = ?body,
- project_ids = ?project_ids,
- "error deleting projects by bulk ids"
- );
-
- return Err(OpensearchClientError::Unknown {
- details: body,
- method: Some("delete_project_bulk_ids".to_string()),
- });
- }
-
- tracing::trace!(project_ids = ?project_ids, "projects deleted successfully");
- Ok(())
-}
-
-/// Deletes all projects with the specified user_id
-#[tracing::instrument(skip(client))]
-pub async fn delete_projects_by_user_id(
- client: &opensearch::OpenSearch,
- user_id: &str,
-) -> Result<()> {
- let query = serde_json::json!({
- "query": {
- "term": {
- "user_id": user_id
- }
- },
- });
-
- let response = client
- .delete_by_query(opensearch::DeleteByQueryParts::Index(&[
- SearchIndex::Projects.as_ref(),
- ]))
- .body(query)
- .refresh(true) // Ensure the index reflects changes immediately
- .send()
- .await
- .map_err(|err| OpensearchClientError::Unknown {
- details: err.to_string(),
- method: Some("delete_projects_by_user_id".to_string()),
- })?;
-
- let status_code = response.status_code();
-
- if !status_code.is_success() {
- let body =
- response
- .text()
- .await
- .map_err(|err| OpensearchClientError::DeserializationFailed {
- details: err.to_string(),
- method: Some("delete_projects_by_user_id".to_string()),
- })?;
-
- tracing::error!(
- status_code = ?status_code,
- body = ?body,
- user_id = %user_id,
- "error deleting projects by user id"
- );
-
- return Err(OpensearchClientError::Unknown {
- details: body,
- method: Some("delete_projects_by_user_id".to_string()),
- });
- }
-
- Ok(())
-}
diff --git a/rust/cloud-storage/opensearch_client/src/lib.rs b/rust/cloud-storage/opensearch_client/src/lib.rs
index ed40d724ab..21ad9e4ad7 100644
--- a/rust/cloud-storage/opensearch_client/src/lib.rs
+++ b/rust/cloud-storage/opensearch_client/src/lib.rs
@@ -12,7 +12,6 @@ pub mod channel_message;
pub mod chat;
pub mod document;
pub mod email;
-pub mod project;
pub type Result<T> = std::result::Result<T, error::OpensearchClientError>;
diff --git a/rust/cloud-storage/opensearch_client/src/project.rs b/rust/cloud-storage/opensearch_client/src/project.rs
deleted file mode 100644
index e4b4bf3c5d..0000000000
--- a/rust/cloud-storage/opensearch_client/src/project.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-use crate::{
- OpensearchClient, Result,
- delete::project::{delete_project_bulk_ids, delete_project_by_id, delete_projects_by_user_id},
- upsert::project::{UpsertProjectArgs, upsert_project},
-};
-
-impl OpensearchClient {
- /// Upserts a project into the opensearch index
- #[tracing::instrument(skip(self))]
- pub async fn upsert_project(&self, args: &UpsertProjectArgs) -> Result<()> {
- upsert_project(&self.inner, args).await
- }
-
- /// Deletes a project from the opensearch project index
- #[tracing::instrument(skip(self))]
- pub async fn delete_project(&self, id: &str) -> Result<()> {
- delete_project_by_id(&self.inner, id).await
- }
-
- /// Deletes a project from the opensearch project index
- #[tracing::instrument(skip(self))]
- pub async fn delete_project_bulk(&self, ids: &Vec<String>) -> Result<()> {
- delete_project_bulk_ids(&self.inner, ids).await
- }
-
- pub async fn delete_projects_by_user_id(&self, user_id: &str) -> Result<()> {
- delete_projects_by_user_id(&self.inner, user_id).await
- }
-}
diff --git a/rust/cloud-storage/opensearch_client/src/upsert/mod.rs b/rust/cloud-storage/opensearch_client/src/upsert/mod.rs
index 78ab6d11f3..313f5e18ee 100644
--- a/rust/cloud-storage/opensearch_client/src/upsert/mod.rs
+++ b/rust/cloud-storage/opensearch_client/src/upsert/mod.rs
@@ -3,4 +3,3 @@ pub mod chat_message;
pub mod document;
pub mod email;
pub mod name;
-pub mod project;
diff --git a/rust/cloud-storage/opensearch_client/src/upsert/project.rs b/rust/cloud-storage/opensearch_client/src/upsert/project.rs
deleted file mode 100644
index 9ab096942e..0000000000
--- a/rust/cloud-storage/opensearch_client/src/upsert/project.rs
+++ /dev/null
@@ -1,59 +0,0 @@
-use models_opensearch::SearchIndex;
-
-use crate::{Result, date_format::EpochSeconds, error::OpensearchClientError};
-
-/// The arguments for upserting a project into the opensearch index
-#[derive(Debug, serde::Serialize)]
-pub struct UpsertProjectArgs {
- #[serde(rename = "entity_id")]
- pub project_id: String,
- pub user_id: String,
- pub project_name: String,
- pub created_at_seconds: EpochSeconds,
- pub updated_at_seconds: EpochSeconds,
-}
-
-#[tracing::instrument(skip(client))]
-pub(crate) async fn upsert_project(
- client: &opensearch::OpenSearch,
- args: &UpsertProjectArgs,
-) -> Result<()> {
- let response = client
- .index(opensearch::IndexParts::IndexId(
- SearchIndex::Projects.as_ref(),
- &args.project_id,
- ))
- .body(args)
- .send()
- .await
- .map_err(|err| OpensearchClientError::DeserializationFailed {
- details: err.to_string(),
- method: Some("upsert_project".to_string()),
- })?;
-
- let status_code = response.status_code();
- if status_code.is_success() {
- tracing::trace!(id=%args.project_id, "project upserted successfully");
- } else {
- let body =
- response
- .text()
- .await
- .map_err(|err| OpensearchClientError::DeserializationFailed {
- details: err.to_string(),
- method: Some("upsert_project".to_string()),
- })?;
-
- tracing::error!(
- status_code=?status_code,
- body=?body,
- "error upserting project",
- );
-
- return Err(OpensearchClientError::Unknown {
- details: body,
- method: Some("upsert_project".to_string()),
- });
- }
- Ok(())
-}
diff --git a/rust/cloud-storage/search_processing_service/Cargo.toml b/rust/cloud-storage/search_processing_service/Cargo.toml
index 32cf38011b..d7b40e69e7 100644
--- a/rust/cloud-storage/search_processing_service/Cargo.toml
+++ b/rust/cloud-storage/search_processing_service/Cargo.toml
@@ -21,11 +21,6 @@ name = "backfill_entity_names"
path = "src/bin/backfill_entity_names.rs"
required-features = ["backfill_names"]
-[[bin]]
-name = "backfill_project"
-path = "src/bin/backfill_project.rs"
-required-features = ["service"]
-
[[bin]]
name = "search_processing_service"
path = "src/main.rs"
diff --git a/rust/cloud-storage/search_processing_service/src/bin/backfill_project.rs b/rust/cloud-storage/search_processing_service/src/bin/backfill_project.rs
deleted file mode 100644
index 6baccf113f..0000000000
--- a/rust/cloud-storage/search_processing_service/src/bin/backfill_project.rs
+++ /dev/null
@@ -1,75 +0,0 @@
-/// backfill_chat.rs is used to trigger a backfill for chats
-/// Required environment variables:
-/// - DATABASE_URL
-/// - SEARCH_TEXT_EXTRACTOR_QUEUE
-use anyhow::Context;
-use macro_entrypoint::MacroEntrypoint;
-use sqlx::postgres::PgPoolOptions;
-use sqs_client::search::project::ProjectMessage;
-
-#[tokio::main]
-async fn main() -> anyhow::Result<()> {
- MacroEntrypoint::default().init();
-
- let database_url = std::env::var("DATABASE_URL").context("DATABASE_URL not set")?;
- let db = PgPoolOptions::new()
- .min_connections(10)
- .max_connections(60)
- .connect(&database_url)
- .await
- .context("could not connect to db")?;
-
- let search_event_queue =
- std::env::var("SEARCH_EVENT_QUEUE").context("SEARCH_EVENT_QUEUE not set")?;
-
- let queue_aws_config = aws_config::defaults(aws_config::BehaviorVersion::latest())
- .region("us-east-1")
- .load()
- .await;
-
- let sqs_client = sqs_client::SQS::new(aws_sdk_sqs::Client::new(&queue_aws_config))
- .search_event_queue(&search_event_queue);
-
- let limit = 5000;
- let mut offset = 0;
- let mut count = 0;
- loop {
- tracing::info!(limit=%limit, offset=%offset, "getting chats");
-
- let projects =
- macro_db_client::projects::get_all_project_ids_with_users_paginated(&db, limit, offset)
- .await?;
- println!("got batch offset {offset}");
-
- if projects.is_empty() {
- tracing::trace!("no more projects found");
- break;
- }
-
- count += projects.len();
-
- tracing::trace!(projects = projects.len(), "ready to queue projects");
-
- sqs_client
- .bulk_send_message_to_search_event_queue(
- projects
- .iter()
- .map(|(project_id, user_id)| {
- sqs_client::search::SearchQueueMessage::ProjectMessage(ProjectMessage {
- project_id: project_id.clone(),
- macro_user_id: user_id.clone(),
- })
- })
- .collect(),
- )
- .await?;
- println!("queued batch");
-
- // // Set offset for next iteration
- offset += limit;
- }
-
- println!("Completed. Total chats processed: {}", count);
-
- Ok(())
-}
diff --git a/rust/cloud-storage/search_processing_service/src/process/mod.rs b/rust/cloud-storage/search_processing_service/src/process/mod.rs
index 5ddf96e260..f5275ffc15 100644
--- a/rust/cloud-storage/search_processing_service/src/process/mod.rs
+++ b/rust/cloud-storage/search_processing_service/src/process/mod.rs
@@ -4,7 +4,6 @@ pub mod context;
mod document;
mod email;
mod name;
-mod project;
mod user;
pub mod worker;
@@ -107,15 +106,6 @@ pub async fn process_message(
SearchQueueMessage::RemoveChatMessage(message) => {
chat::remove_chat_message(&ctx.opensearch_client, &message).await?;
}
- SearchQueueMessage::ProjectMessage(message) => {
- project::insert_project(&ctx.opensearch_client, &ctx.db, &message).await?;
- }
- SearchQueueMessage::RemoveProjectMessage(message) => {
- project::remove_project(&ctx.opensearch_client, &message).await?;
- }
- SearchQueueMessage::BulkRemoveProjectMessage(message) => {
- project::remove_project_bulk(&ctx.opensearch_client, &message).await?;
- }
}
ctx.worker.cleanup_message(message).await?;
diff --git a/rust/cloud-storage/search_processing_service/src/process/project.rs b/rust/cloud-storage/search_processing_service/src/process/project.rs
deleted file mode 100644
index 7bde943bd6..0000000000
--- a/rust/cloud-storage/search_processing_service/src/process/project.rs
+++ /dev/null
@@ -1,68 +0,0 @@
-use opensearch_client::{
- OpensearchClient, date_format::EpochSeconds, upsert::project::UpsertProjectArgs,
-};
-use sqs_client::search::project::{BulkRemoveProjectMessage, ProjectMessage};
-
-/// Handles the processing of project messages
-#[tracing::instrument(skip(opensearch_client, db))]
-pub async fn insert_project(
- opensearch_client: &OpensearchClient,
- db: &sqlx::Pool<sqlx::Postgres>,
- message: &ProjectMessage,
-) -> anyhow::Result<()> {
- let project =
- macro_db_client::projects::get_project::get_project_by_id(db.clone(), &message.project_id)
- .await;
-
- let project = match project {
- Ok(project) => project,
- Err(e) => match e {
- sqlx::Error::RowNotFound => {
- return Ok(());
- }
- _ => {
- anyhow::bail!("unable to get project info")
- }
- },
- };
-
- let upsert_project_args = UpsertProjectArgs {
- project_id: project.id,
- user_id: project.user_id,
- created_at_seconds: EpochSeconds::new(project.created_at.unwrap_or_default().timestamp())?,
- updated_at_seconds: EpochSeconds::new(project.updated_at.unwrap_or_default().timestamp())?,
- project_name: project.name,
- };
-
- opensearch_client
- .upsert_project(&upsert_project_args)
- .await?;
-
- Ok(())
-}
-
-/// Handles the removeal of projects
-#[tracing::instrument(skip(opensearch_client))]
-pub async fn remove_project(
- opensearch_client: &OpensearchClient,
- message: &ProjectMessage,
-) -> anyhow::Result<()> {
- opensearch_client
- .delete_project(&message.project_id)
- .await?;
-
- Ok(())
-}
-
-/// Bulk remove projects
-#[tracing::instrument(skip(opensearch_client))]
-pub async fn remove_project_bulk(
- opensearch_client: &OpensearchClient,
- message: &BulkRemoveProjectMessage,
-) -> anyhow::Result<()> {
- opensearch_client
- .delete_project_bulk(&message.project_ids)
- .await?;
-
- Ok(())
-}
diff --git a/rust/cloud-storage/search_processing_service/src/process/user.rs b/rust/cloud-storage/search_processing_service/src/process/user.rs
index b71d723ffd..df90ee9615 100644
--- a/rust/cloud-storage/search_processing_service/src/process/user.rs
+++ b/rust/cloud-storage/search_processing_service/src/process/user.rs
@@ -24,11 +24,6 @@ pub async fn remove_user_profile(
.delete_email_messages_by_user_id(user_profile_id)
.await?;
- // Delete projects of user
- opensearch_client
- .delete_projects_by_user_id(user_profile_id)
- .await?;
-
opensearch_client
.delete_entities_for_user(user_profile_id)
.await?;
diff --git a/rust/cloud-storage/sqs_client/src/search/mod.rs b/rust/cloud-storage/sqs_client/src/search/mod.rs
index bcc2bc80bc..1d41ff3bef 100644
--- a/rust/cloud-storage/sqs_client/src/search/mod.rs
+++ b/rust/cloud-storage/sqs_client/src/search/mod.rs
@@ -6,7 +6,6 @@ use crate::{
document::{DocumentId, SearchExtractorMessage},
email::{EmailLinkMessage, EmailMessage, EmailThreadMessage},
name::EntityName,
- project::{BulkRemoveProjectMessage, ProjectMessage},
},
};
use anyhow::Context;
@@ -19,7 +18,6 @@ pub mod chat;
pub mod document;
pub mod email;
pub mod name;
-pub mod project;
use crate::{MAX_BATCH_SIZE, PrimaryId};
@@ -83,10 +81,6 @@ pub enum SearchQueueMessage {
// Channel
ChannelMessageUpdate(ChannelMessageUpdate),
RemoveChannelMessage(RemoveChannelMessage),
- // Project
- ProjectMessage(ProjectMessage),
- RemoveProjectMessage(ProjectMessage),
- BulkRemoveProjectMessage(BulkRemoveProjectMessage),
// User
RemoveUserProfile(String),
@@ -117,10 +111,6 @@ impl PrimaryId for SearchQueueMessage {
message.message_id.clone().unwrap_or_default()
)
}
- SearchQueueMessage::ProjectMessage(message) => message.project_id.clone(),
- SearchQueueMessage::RemoveProjectMessage(message) => message.project_id.clone(),
- // NOTE: this trait might not make sense for bulk remove
- SearchQueueMessage::BulkRemoveProjectMessage(message) => message.project_ids[0].clone(),
SearchQueueMessage::RemoveUserProfile(message) => message.clone(),
@@ -148,10 +138,6 @@ impl SearchQueueMessage {
// Channels
SearchQueueMessage::ChannelMessageUpdate(_) => Operation::ExtractText,
SearchQueueMessage::RemoveChannelMessage(_) => Operation::Remove,
- // Projects
- SearchQueueMessage::ProjectMessage(_) => Operation::UpdateMetadata,
- SearchQueueMessage::RemoveProjectMessage(_) => Operation::Remove,
- SearchQueueMessage::BulkRemoveProjectMessage(_) => Operation::Remove,
// Users
SearchQueueMessage::RemoveUserProfile(_) => Operation::Remove,
// Entity Name
diff --git a/rust/cloud-storage/sqs_client/src/search/project.rs b/rust/cloud-storage/sqs_client/src/search/project.rs
deleted file mode 100644
index a8dd801c75..0000000000
--- a/rust/cloud-storage/sqs_client/src/search/project.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Debug)]
-pub struct ProjectMessage {
- /// The project id
- pub project_id: String,
- /// The macro user id of the user who owns this project
- pub macro_user_id: String,
-}
-
-#[derive(serde::Serialize, serde::Deserialize, PartialEq, Eq, Debug)]
-pub struct BulkRemoveProjectMessage {
- pub project_ids: Vec<String>,
-}