Skip to content

Commit

Permalink
refactor(airport, aircraft): split core and search
Browse files Browse the repository at this point in the history
- more idiomatic custom aircraft and search
- cross-column suggestions for airport and aircraft
- add tests
- generalise queue suggestions to utils
  • Loading branch information
cathaypacific8747 committed May 31, 2024
1 parent 49a663f commit 46a2b64
Show file tree
Hide file tree
Showing 14 changed files with 1,071 additions and 569 deletions.
288 changes: 288 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions am4-cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
use am4::aircraft::search::Aircrafts;
// use am4::airport::Airports;
// use std::rc::Rc;
// use am4::airport::search::Airports;

// NOTE: directory is CWD, not the location of the executable.
fn main() {
// NOTE: directory is CWD, not the location of the executable.
// let airports = Airports::from_csv("am4/data/airports.csv").unwrap();
// println!("{:#?}", airports);
// let index = airports.indexed();

// let a1 = airports.search("iata:hkgA");
// let suggestions = airports.suggest("iata:hkgA");
// println!("{:#?}", index.search("iata:hkg"));
// println!("{:#?}", index.suggest("vhhx"));

// println!("{:#?}", suggestions)
// let maxln = airports.data.iter().max_by_key(|a| a.name.0.len()).unwrap();
// println!("{:#?}", maxln.name.0.len());

let binding = Aircrafts::from_csv("am4/data/aircrafts.csv").unwrap();
let aircrafts = binding.indexed();
println!("{:#?}", aircrafts.search("a388[s]"));
println!("{:#?}", aircrafts.search("a388"));
let aircrafts = Aircrafts::from_csv("am4/data/aircrafts.csv").unwrap();
let index = aircrafts.indexed();
// println!("{:#?}", index.search("name:B747-4000"));
println!("{:#?}", index.suggest("shortname:b7440"));
}
4 changes: 4 additions & 0 deletions am4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ csv = "1.3.0"
jaro_winkler = "0.1.0"
serde = { version = "1.0.203", features = ["derive"] }
thiserror = "1.0.61"

[dev-dependencies]
rstest = "0.20.0"
once_cell = "1.19.0"
Loading

0 comments on commit 46a2b64

Please sign in to comment.