Set host, port, check folder to env variables

master
Griffiths Lott 3 years ago
parent de68bbaeea
commit 9127213ce9
  1. 1144
      Cargo.lock
  2. 8
      Cargo.toml
  3. 9
      src/main.rs

1144
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -9,7 +9,11 @@ edition = "2021"
tiberius = {version = "0.11.2", features = ["winauth", "rust_decimal", "chrono"]}
tokio = {version = "1.21.2", features = ["full"]}
tokio-util = {version = "0.7.4", features = ["full"]}
connectorx = {version = "0.2.5"}
polars = {version = "0.24.3"}
chrono = {version = "0.4.22", features = ["serde"]}
actix-web = "4"
serde = {version = "1.0.147", features = ["derive"]}
serde_json = "1.0.87"
walkdir = "2.3.2"
dotenv = "0.15.0"

@ -40,8 +40,8 @@ async fn search_contract(contract_number: web::Path<String>) -> HttpResponse {
let mut resp = SearchResponse{paid_in_full: vec![], checks: None};
dotenv().ok();
let mut config = Config::new();
config.host("172.16.181.143");
config.port(1433);
config.host(var("HOST").expect("No HOST set in .env"));
config.port(var("PORT").expect("No HOST set in .env").parse::<u16>().expect("Could not parse port to u16"));
config.authentication(AuthMethod::windows(var("USER_NAME").expect("No USER_NAME set in .env"), var("PASSWORD").expect("No PASSWORD set in .env")));
config.trust_cert(); // on production, it is not a good idea to do this
@ -111,7 +111,10 @@ async fn find_checks(config: Config, search_data: Vec<(String, String, NaiveDate
for row in rows {
let check_number: &str = row.get("CHEKNUMB").unwrap();
let vendor: &str = row.get("VENDORID").unwrap();
let files: Vec<DirEntry> = WalkDir::new(&format!("\\\\LCCPHL-SSFSH001\\Mekorma PDF\\NLCF\\PROCESSED\\*{}*",check_number)).into_iter().filter_map(|e| e.ok()).collect();
let files: Vec<DirEntry> = WalkDir::new(&format!("{}*{}*",
var("CHECK_FOLDER").expect("No HOST set in .env") ,check_number))
.into_iter().filter_map(|e| e.ok())
.collect();
if files.len() > 0 {found_checks.push([vendor.to_string(), files[0].file_name().to_str().unwrap().to_string()])}
}
}

Loading…
Cancel
Save