Skip to content

Commit

Permalink
cleanup: change event types to be chunk_ instead of card_
Browse files Browse the repository at this point in the history
  • Loading branch information
skeptrunedev authored and cdxker committed Apr 9, 2024
1 parent c443cd4 commit 54b140f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 21 deletions.
6 changes: 3 additions & 3 deletions dashboard/src/pages/Dashboard/Dataset/DatasetEvents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export const DatasetEvents = () => {
name: "File Uploaded",
},
{
id: "card_action_failed",
id: "chunk_action_failed",
name: "Chunk Upload Failed",
},
{
id: "card_uploaded",
id: "chunk_uploaded",
name: "Chunk Uploaded",
},
{
id: "card_updated",
id: "chunk_updated",
name: "Chunk Updated",
},
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- This file should undo anything in `up.sql`
UPDATE events
SET event_type = REPLACE(event_type, 'chunk_', 'card_')
WHERE event_type LIKE 'chunk_%';
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Your SQL goes here
UPDATE events
SET event_type = REPLACE(event_type, 'card_', 'chunk_')
WHERE event_type LIKE 'card_%';
6 changes: 3 additions & 3 deletions server/src/bin/ingestion-microservice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ async fn ingestion_service(
let _ = create_event_query(
Event::from_details(
payload.ingest_specific_chunk_metadata.dataset_id,
models::EventType::CardUploaded {
models::EventType::ChunkUploaded {
chunk_id: payload.ingest_specific_chunk_metadata.id,
},
),
Expand Down Expand Up @@ -295,7 +295,7 @@ async fn ingestion_service(
let _ = create_event_query(
Event::from_details(
payload.dataset_id,
models::EventType::CardUpdated {
models::EventType::ChunkUpdated {
chunk_id: payload.chunk_metadata.id,
},
),
Expand Down Expand Up @@ -696,7 +696,7 @@ pub async fn readd_error_to_queue(
let _ = create_event_query(
Event::from_details(
message.get_dataset_id(),
models::EventType::CardActionFailed {
models::EventType::ChunkActionFailed {
chunk_id: message.get_chunkmetadata_id(),
error: format!(
"Failed to upload chunk with tracking_id: {:?}: {:?}",
Expand Down
24 changes: 12 additions & 12 deletions server/src/data/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1002,14 +1002,14 @@ pub enum EventType {
group_id: uuid::Uuid,
file_name: String,
},
CardUploaded {
ChunkUploaded {
chunk_id: uuid::Uuid,
},
CardActionFailed {
ChunkActionFailed {
chunk_id: uuid::Uuid,
error: String,
},
CardUpdated {
ChunkUpdated {
chunk_id: uuid::Uuid,
},
}
Expand All @@ -1018,18 +1018,18 @@ impl EventType {
pub fn as_str(&self) -> String {
match self {
EventType::FileUploaded { .. } => "file_uploaded".to_string(),
EventType::CardUploaded { .. } => "card_uploaded".to_string(),
EventType::CardActionFailed { .. } => "card_action_failed".to_string(),
EventType::CardUpdated { .. } => "card_updated".to_string(),
EventType::ChunkUploaded { .. } => "chunk_uploaded".to_string(),
EventType::ChunkActionFailed { .. } => "chunk_action_failed".to_string(),
EventType::ChunkUpdated { .. } => "chunk_updated".to_string(),
}
}

pub fn get_all_event_types() -> Vec<String> {
vec![
"file_uploaded".to_string(),
"card_uploaded".to_string(),
"card_action_failed".to_string(),
"card_updated".to_string(),
"chunk_uploaded".to_string(),
"chunk_action_failed".to_string(),
"chunk_updated".to_string(),
]
}
}
Expand All @@ -1043,11 +1043,11 @@ impl From<EventType> for serde_json::Value {
} => {
json!({"group_id": group_id, "file_name": file_name})
}
EventType::CardUploaded { chunk_id } => json!({"chunk_id": chunk_id}),
EventType::CardActionFailed { chunk_id, error } => {
EventType::ChunkUploaded { chunk_id } => json!({"chunk_id": chunk_id}),
EventType::ChunkActionFailed { chunk_id, error } => {
json!({"chunk_id": chunk_id, "error": error})
}
EventType::CardUpdated { chunk_id } => json!({"chunk_id": chunk_id}),
EventType::ChunkUpdated { chunk_id } => json!({"chunk_id": chunk_id}),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions server/src/handlers/event_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ use utoipa::{schema, ToSchema};
#[schema(example = json!({
"page": 1,
"page_size": 10,
"type": ["card_action_failed"]
"type": ["chunk_action_failed"]
}))]
pub struct GetEventsData {
/// The page number to get. Default is 1.
pub page: Option<i64>,
/// The number of items per page. Default is 10.
pub page_size: Option<i64>,
/// The types of events to get. Any combination of file_uploaded, card_uploaded, card_action_failed, or card_updated. Leave undefined to get all events.
/// The types of events to get. Any combination of file_uploaded, chunk_uploaded, chunk_action_failed, or chunk_updated. Leave undefined to get all events.
pub event_types: Option<Vec<String>>,
}

Expand Down
2 changes: 1 addition & 1 deletion server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl Modify for SecurityAddon {
name = "BSL",
url = "https://github.com/devflowinc/trieve/blob/main/LICENSE.txt",
),
version = "0.6.0",
version = "0.6.1",
),
servers(
(url = "https://api.trieve.ai",
Expand Down

0 comments on commit 54b140f

Please sign in to comment.