Skip to content

Commit

Permalink
Fix issues rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Feb 3, 2025
1 parent c69e268 commit 02d76d3
Show file tree
Hide file tree
Showing 12 changed files with 8,476 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function TableExportDialog({
bindShow,
}: TableExportDialogProps): React.JSX.Element {
const store = useStore();
const [dialogProps, showDialog] = useDialog({ bindShow });
const { dialogProps, show: showDialog } = useDialog({ bindShow });
const [refAsSubject, setRefAsSubject] = useState(false);

const url = buildLink(subject, refAsSubject, store);
Expand Down
8,382 changes: 8,382 additions & 0 deletions browser/deno.lock

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions lib/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ impl Db {
Ok(())
}

/// Closes the database.
pub fn flush(&self) -> AtomicResult<()> {
self.db.flush()?;
Ok(())
}

/// Internal method for fetching Resource data.
#[instrument(skip(self))]
fn set_propvals(&self, subject: &str, propvals: &PropVals) -> AtomicResult<()> {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/db/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fn res_v1_to_v2(store: &Db) -> AtomicResult<()> {
Ok(url) => url,
Err(e) => {
tracing::error!(
"Unable to parse subject URL of '{}', skipping: {}",
"Unable to parse subject URL of '{}', keeping original: {}",
subject,
e
);
Expand Down
146 changes: 81 additions & 65 deletions lib/src/db/query_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,79 +491,95 @@ pub mod test {

#[test]
fn should_update_or_not() {
let store = &Db::init_temp("should_update_or_not").unwrap();
let instant = std::time::Instant::now();

let prop = urls::IS_A.to_string();
let class = urls::AGENT;
{
let store = &Db::init_temp("should_update_or_not").unwrap();

let qf_prop_val = QueryFilter {
property: Some(prop.clone()),
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: None,
};
let prop = urls::IS_A.to_string();
let class = urls::AGENT;

let qf_prop = QueryFilter {
property: Some(prop.clone()),
value: None,
sort_by: None,
};
let qf_prop_val = QueryFilter {
property: Some(prop.clone()),
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: None,
};

let qf_val = QueryFilter {
property: None,
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: None,
};
let qf_prop = QueryFilter {
property: Some(prop.clone()),
value: None,
sort_by: None,
};

let resource_correct_class = Resource::new_instance(class, store).unwrap();
let qf_val = QueryFilter {
property: None,
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: None,
};

let subject: String = "https://example.com/someAgent".into();
let resource_correct_class = Resource::new_instance(class, store).unwrap();

let index_atom = IndexAtom {
subject,
property: prop.clone(),
ref_value: class.to_string(),
sort_value: class.to_string(),
};
let subject: String = "https://example.com/someAgent".into();

// We should be able to find the resource by propval, val, and / or prop.
assert!(should_update_property(&qf_val, &index_atom, &resource_correct_class).is_some());
assert!(
should_update_property(&qf_prop_val, &index_atom, &resource_correct_class,).is_some()
);
assert!(should_update_property(&qf_prop, &index_atom, &resource_correct_class).is_some());

// Test when a different value is passed
let resource_wrong_class = Resource::new_instance(urls::PARAGRAPH, store).unwrap();
assert!(should_update_property(&qf_prop, &index_atom, &resource_wrong_class).is_some());
assert!(should_update_property(&qf_val, &index_atom, &resource_wrong_class).is_none());
assert!(should_update_property(&qf_prop_val, &index_atom, &resource_wrong_class).is_none());

let qf_prop_val_sort = QueryFilter {
property: Some(prop.clone()),
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: Some(urls::DESCRIPTION.to_string()),
};
let qf_prop_sort = QueryFilter {
property: Some(prop.clone()),
value: None,
sort_by: Some(urls::DESCRIPTION.to_string()),
};
let qf_val_sort = QueryFilter {
property: Some(prop),
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: Some(urls::DESCRIPTION.to_string()),
};
let index_atom = IndexAtom {
subject,
property: prop.clone(),
ref_value: class.to_string(),
sort_value: class.to_string(),
};

// We should update with a sort_by attribute
assert!(
should_update_property(&qf_prop_val_sort, &index_atom, &resource_correct_class,)
.is_some()
);
assert!(
should_update_property(&qf_prop_sort, &index_atom, &resource_correct_class,).is_some()
);
assert!(
should_update_property(&qf_val_sort, &index_atom, &resource_correct_class,).is_some()
);
// We should be able to find the resource by propval, val, and / or prop.
assert!(
should_update_property(&qf_val, &index_atom, &resource_correct_class).is_some()
);
assert!(
should_update_property(&qf_prop_val, &index_atom, &resource_correct_class,)
.is_some()
);
assert!(
should_update_property(&qf_prop, &index_atom, &resource_correct_class).is_some()
);

// Test when a different value is passed
let resource_wrong_class = Resource::new_instance(urls::PARAGRAPH, store).unwrap();
assert!(should_update_property(&qf_prop, &index_atom, &resource_wrong_class).is_some());
assert!(should_update_property(&qf_val, &index_atom, &resource_wrong_class).is_none());
assert!(
should_update_property(&qf_prop_val, &index_atom, &resource_wrong_class).is_none()
);

let qf_prop_val_sort = QueryFilter {
property: Some(prop.clone()),
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: Some(urls::DESCRIPTION.to_string()),
};
let qf_prop_sort = QueryFilter {
property: Some(prop.clone()),
value: None,
sort_by: Some(urls::DESCRIPTION.to_string()),
};
let qf_val_sort = QueryFilter {
property: Some(prop),
value: Some(Value::AtomicUrl(class.to_string())),
sort_by: Some(urls::DESCRIPTION.to_string()),
};

// We should update with a sort_by attribute
assert!(should_update_property(
&qf_prop_val_sort,
&index_atom,
&resource_correct_class,
)
.is_some());
assert!(
should_update_property(&qf_prop_sort, &index_atom, &resource_correct_class,)
.is_some()
);
assert!(
should_update_property(&qf_val_sort, &index_atom, &resource_correct_class,)
.is_some()
);
}
println!("Took {:?}", instant.elapsed())
}
}
1 change: 0 additions & 1 deletion lib/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,6 @@ mod test {
validate_signature: true,
validate_timestamp: true,
validate_rights: false,
validate_subject_url_parent: true,
validate_previous_commit: true,
validate_for_agent: None,
update_index: true,
Expand Down
2 changes: 1 addition & 1 deletion lib/src/serialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ mod test {

#[test]
fn serialize_json_ad() {
let mut store = crate::Store::init().unwrap();
let store = crate::Store::init().unwrap();
store.populate().unwrap();
let json = store
.get_resource(crate::urls::AGENT)
Expand Down
2 changes: 1 addition & 1 deletion lib/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ mod test {
use crate::{agents::ForAgent, urls, Value};

fn init_store() -> Store {
let mut store = Store::init().unwrap();
let store = Store::init().unwrap();
store.populate().unwrap();
store
}
Expand Down
3 changes: 0 additions & 3 deletions server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ fn main() -> std::io::Result<()> {
// return Ok(());
const BROWSER_ROOT: &str = "../browser/";
println!("cargo:rerun-if-changed={}", BROWSER_ROOT);
// Check if we're likely running in a check-like context
let opt_level = std::env::var("OPT_LEVEL").unwrap_or_else(|_| "0".to_string());
let profile = std::env::var("PROFILE").unwrap_or_else(|_| "release".to_string());

let is_check_like = false; // profile == "debug" && opt_level == "0";

Expand Down
1 change: 1 addition & 0 deletions server/src/appstate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl AppState {
/// Cleanup code, writing buffers, committing changes, etc.
fn exit(&self) -> AtomicServerResult<()> {
self.search_state.writer.write()?.commit()?;
self.store.flush()?;
Ok(())
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/src/commit_monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl CommitMonitor {
impl Handler<CommitMessage> for CommitMonitor {
type Result = ();

#[tracing::instrument(name = "handle_commit_message", skip_all, fields(subscriptions = &self.subscriptions.len(), s = %msg.commit_response.commit_resource.get_subject()))]
#[tracing::instrument(name = "handle_commit_message", level="debug", skip_all, fields(subscriptions = &self.subscriptions.len(), s = %msg.commit_response.commit_resource.get_subject()))]
fn handle(&mut self, msg: CommitMessage, _: &mut Context<Self>) {
// We have moved the logic to the `handle_internal` function for decent error handling
match self.handle_internal(msg) {
Expand Down
1 change: 1 addition & 0 deletions server/src/serve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pub async fn serve(config: crate::config::Config) -> AtomicServerResult<()> {
if let Some(guard) = tracing_chrome_flush_guard {
guard.flush()
}
drop(config);

tracing::info!("Server stopped");
Ok(())
Expand Down

0 comments on commit 02d76d3

Please sign in to comment.