Temporal todo
This commit is contained in:
1 parent
55bdc5a7ad
commit
1509947cb0
3 files changed
+74
-69
No files matched your search
+42
-41
@@ -111,47 +111,48 @@ impl DeckSettings {
|
||||
ast.is_ok()
|
||||
}
|
||||
pub fn get_word_list(&self, state: &AppState) -> Vec<usize> {
|
||||
let time = Instant::now();
|
||||
let mut list = vec![];
|
||||
let engine = Engine::new();
|
||||
|
||||
let ast = engine.compile(&self.filter);
|
||||
if let Ok(ast) = ast {
|
||||
let groups = state.word_groups.read();
|
||||
let query = state
|
||||
.dictionary.read().query_par(| word: &WordData|{
|
||||
let mut more = rhai::Map::new();
|
||||
for iced in &word.additional {
|
||||
more.insert(iced.0.clone().into(), iced.1.clone().into());
|
||||
}
|
||||
let mut scope = Scope::new();
|
||||
let group_name = groups.get_ref(&mut groups.handle_by_id(word.group_id)).unwrap().name;
|
||||
|
||||
scope
|
||||
.push_constant("id", word.id.0 as i64)
|
||||
.push_constant("key", word.key.clone())
|
||||
.push_constant("value", word.value.clone())
|
||||
.push_constant("tags", word.tags.clone())
|
||||
.push_constant("more", more)
|
||||
.push_constant(
|
||||
"group",
|
||||
group_name,
|
||||
);
|
||||
|
||||
let result = engine.eval_ast_with_scope::<bool>(&mut scope, &ast);
|
||||
if let Ok(result) = result {
|
||||
return result;
|
||||
}
|
||||
false
|
||||
});
|
||||
|
||||
|
||||
info!("Collecting available words is {:?}", time.elapsed());
|
||||
|
||||
list
|
||||
} else {
|
||||
list
|
||||
}
|
||||
todo!()
|
||||
// let time = Instant::now();
|
||||
// let mut list = vec![];
|
||||
// let engine = Engine::new();
|
||||
//
|
||||
// let ast = engine.compile(&self.filter);
|
||||
// if let Ok(ast) = ast {
|
||||
// let groups = state.word_groups.read();
|
||||
// let query = state
|
||||
// .dictionary.read().query_par(| word: &WordData|{
|
||||
// let mut more = rhai::Map::new();
|
||||
// for iced in &word.additional {
|
||||
// more.insert(iced.0.clone().into(), iced.1.clone().into());
|
||||
// }
|
||||
// let mut scope = Scope::new();
|
||||
// let group_name = groups.get_ref(&mut groups.handle_by_id(word.group_id)).unwrap().name;
|
||||
//
|
||||
// scope
|
||||
// .push_constant("id", word.id.0 as i64)
|
||||
// .push_constant("key", word.key.clone())
|
||||
// .push_constant("value", word.value.clone())
|
||||
// .push_constant("tags", word.tags.clone())
|
||||
// .push_constant("more", more)
|
||||
// .push_constant(
|
||||
// "group",
|
||||
// group_name,
|
||||
// );
|
||||
//
|
||||
// let result = engine.eval_ast_with_scope::<bool>(&mut scope, &ast);
|
||||
// if let Ok(result) = result {
|
||||
// return result;
|
||||
// }
|
||||
// false
|
||||
// });
|
||||
//
|
||||
//
|
||||
// info!("Collecting available words is {:?}", time.elapsed());
|
||||
//
|
||||
// list
|
||||
// } else {
|
||||
// list
|
||||
// }
|
||||
}
|
||||
pub fn require_speech(&self) -> bool {
|
||||
self.forward == "speech" || self.backward == "speech"
|
||||
|
||||
Reference in new issue
Block a user