Recently, I’m implementing the feature to search custom data in the card browser. Via the hook of browser_did_search, it is easy to filter the ids with custom search node.
def _on_browser_did_search_handle_custom_search_parameters(ctx: SearchContext):
global custom_search_nodes
if not custom_search_nodes:
return
try:
original_ids = ctx.ids
for node in custom_search_nodes:
ctx.ids = node.filter_ids(ctx.ids)
ctx.ids = [id for id in original_ids if id in ctx.ids]
except ValueError as e:
showWarning(f"FSRS search error: {e}")
return
finally:
custom_search_nodes = []
It is helpful to filter cards whose retention is lower than a specific threshold. I want to support this feature in the filtered deck. According to my knowledge, there is no way to hook the search of filtered deck because it is running in the Rust backend:
To achieve good performance and make it work across platforms, it is probably best done by extending the existing prop: syntax. The existing property searches reference sql columns, so we’d also need to introduce a custom SQL function like custom_data_f64(key: string).