Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(index): delete skipped documents for StructuredDoc #3463

Merged
merged 9 commits into from
Nov 25, 2024
6 changes: 6 additions & 0 deletions crates/tabby-index/src/structured_doc/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
use super::{create_structured_doc_builder, types::BuildStructuredDoc};
use crate::{indexer::TantivyDocBuilder, Indexer};

/// StructuredDocState is used to track the state of the document source.
/// It is used to determine whether the document should be updated or deleted.
pub struct StructuredDocState {
// updated_at is the time when the document was last updated.
wsxiaoys marked this conversation as resolved.
Show resolved Hide resolved
pub updated_at: DateTime<Utc>,
// deleted indecates whether the document should be deleted in indexer
wsxiaoys marked this conversation as resolved.
Show resolved Hide resolved
// for example, a closed pull request will be marked as deleted, and
// the indexer will remove it from the index.
pub deleted: bool,
}

Expand All @@ -37,7 +43,7 @@
}

if state.deleted {
return self.delete(document.id()).await;

Check warning on line 46 in crates/tabby-index/src/structured_doc/public.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-index/src/structured_doc/public.rs#L46

Added line #L46 was not covered by tests
}

stream! {
Expand All @@ -53,14 +59,14 @@
true
}

pub async fn delete(&self, id: &str) -> bool {
if self.indexer.is_indexed(id) {
self.indexer.delete(id);
true

Check warning on line 65 in crates/tabby-index/src/structured_doc/public.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-index/src/structured_doc/public.rs#L62-L65

Added lines #L62 - L65 were not covered by tests
} else {
false

Check warning on line 67 in crates/tabby-index/src/structured_doc/public.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-index/src/structured_doc/public.rs#L67

Added line #L67 was not covered by tests
}
}

Check warning on line 69 in crates/tabby-index/src/structured_doc/public.rs

View check run for this annotation

Codecov / codecov/patch

crates/tabby-index/src/structured_doc/public.rs#L69

Added line #L69 was not covered by tests

pub fn commit(self) {
self.indexer.commit();
Expand Down

This file was deleted.

Loading