Skip to content

Commit 02de4f0

Browse files
committed
tiered mt and nuc
1 parent 66f8032 commit 02de4f0

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

src/sauce/home.rs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,25 @@ pub fn home() -> Html {
320320
}
321321
None => true,
322322
};
323+
let has_nucleons_exact = match nucleons_search {
324+
Some(ref term) => {
325+
mock_data.data.iter().any(|entry| entry.nucleons.to_string() == *term)
326+
}
327+
None => true,
328+
};
323329
let has_reaction_exact = match reaction_search {
324330
Some(ref term) => {
325331
let term_lower = term.to_lowercase();
326332
mock_data.data.iter().any(|entry| entry.reaction.to_lowercase() == term_lower)
327333
}
328334
None => true,
329335
};
336+
let has_mt_exact = match mt_search {
337+
Some(ref term) => {
338+
mock_data.data.iter().any(|entry| entry.mt.to_string() == *term)
339+
}
340+
None => true,
341+
};
330342
let has_library_exact = match library_search {
331343
Some(ref term) => {
332344
let term_lower = term.to_lowercase();
@@ -359,7 +371,14 @@ pub fn home() -> Html {
359371
None => true,
360372
};
361373
let nucleons_match = match nucleons_search {
362-
Some(ref term) => nucleons.to_string() == *term,
374+
Some(ref term) => {
375+
let nucleons_str = nucleons.to_string();
376+
if has_nucleons_exact {
377+
nucleons_str == *term
378+
} else {
379+
nucleons_str.starts_with(term)
380+
}
381+
}
363382
None => true,
364383
};
365384
let reaction_match = match reaction_search {
@@ -375,7 +394,14 @@ pub fn home() -> Html {
375394
None => true,
376395
};
377396
let mt_match = match mt_search {
378-
Some(ref term) => mt.to_string() == *term,
397+
Some(ref term) => {
398+
let mt_str = mt.to_string();
399+
if has_mt_exact {
400+
mt_str == *term
401+
} else {
402+
mt_str.starts_with(term)
403+
}
404+
}
379405
None => true,
380406
};
381407
let library_match = match library_search {

0 commit comments

Comments
 (0)