mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 15:19:58 -07:00
server: use query for search
This commit is contained in:
@@ -5,9 +5,14 @@ use serde::Deserialize;
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum, Deserialize)]
|
||||
pub enum Format {
|
||||
#[serde(alias = "json")]
|
||||
JSON,
|
||||
#[serde(alias = "csv")]
|
||||
CSV,
|
||||
#[serde(alias = "tsv")]
|
||||
TSV,
|
||||
#[serde(alias = "md", alias = "markdown")]
|
||||
#[value(alias("markdown"))]
|
||||
MD,
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ impl Index {
|
||||
impl TryFrom<&str> for Index {
|
||||
type Error = color_eyre::Report;
|
||||
fn try_from(value: &str) -> Result<Self, Self::Error> {
|
||||
Ok(match value {
|
||||
Ok(match value.to_lowercase().as_str() {
|
||||
v if (Self::Dateindex).possible_values().contains(&v) => Self::Dateindex,
|
||||
v if (Self::Height).possible_values().contains(&v) => Self::Height,
|
||||
v if (Self::Txindex).possible_values().contains(&v) => Self::Txindex,
|
||||
|
||||
@@ -60,8 +60,17 @@ impl<'a> Query<'a> {
|
||||
) -> color_eyre::Result<Output> {
|
||||
let tuples = ids
|
||||
.iter()
|
||||
.map(|s| {
|
||||
let mut id = s.to_lowercase().replace("_", "-");
|
||||
.flat_map(|s| {
|
||||
s.to_lowercase()
|
||||
.replace("_", "-")
|
||||
.split_whitespace()
|
||||
.flat_map(|s| {
|
||||
s.split(',')
|
||||
.flat_map(|s| s.split('+').map(|s| s.to_string()))
|
||||
})
|
||||
.collect::<Vec<_>>()
|
||||
})
|
||||
.map(|mut id| {
|
||||
let mut res = self.vecid_to_index_to_vec.get(&id);
|
||||
if res.is_none() {
|
||||
if let Ok(index) = Index::try_from(id.as_str()) {
|
||||
|
||||
Reference in New Issue
Block a user