aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGalen Guyer <galen@galenguyer.com>2023-01-23 13:05:50 -0500
committerGalen Guyer <galen@galenguyer.com>2023-01-23 13:05:50 -0500
commit367d82ddf594030aaaff0d414ace6cfed2302ca7 (patch)
tree4e76a7804d4eeea2242f818f15382f14d8967e9e
parent58d9842821f6aa8c420c667948b961f55eea4be4 (diff)
move db updates into own bin
-rw-r--r--src/bin/update-db.rs (renamed from src/main.rs)23
-rw-r--r--src/lib.rs7
2 files changed, 9 insertions, 21 deletions
diff --git a/src/main.rs b/src/bin/update-db.rs
index db56c1f..660407d 100644
--- a/src/main.rs
+++ b/src/bin/update-db.rs
@@ -3,13 +3,8 @@ use regex::Regex;
use sqlx::sqlite::SqlitePool;
use std::{fs, os::unix::prelude::MetadataExt, time::Duration};
-mod fcc_date;
-mod file;
-mod load;
-mod meta;
-mod types;
-use file::{download_file, unzip_file};
-use types::Update;
+use artemis::{meta, load, Update};
+use artemis::file::{unzip_file, download_file};
const WEEKLY_DUMP_URL: &str = "https://data.fcc.gov/download/pub/uls/complete/l_amat.zip";
const SUNDAY_DUMP_URL: &str = "https://data.fcc.gov/download/pub/uls/daily/l_am_sun.zip";
@@ -159,20 +154,6 @@ async fn load_weekly(db: &SqlitePool) -> chrono::DateTime<Utc> {
async fn load_daily(url: &str, db: &SqlitePool) -> chrono::DateTime<Utc> {
- let parse_file_name_from_url = |url: &str| {
- let output_file_name_regex = Regex::new(r"/(\w+\.?\w*)").expect("Error constructing regex");
- let Some(file_name_captures) = output_file_name_regex.captures_iter(url).last() else {
- panic!("Error parsing file name from URL");
- };
- let Some(maybe_match) = file_name_captures.iter().last() else {
- panic!("Error parsing file name from URL");
- };
- let Some(file_name_match) = maybe_match else {
- panic!("Error parsing file name from URL");
- };
- String::from(file_name_match.as_str())
- };
-
let output_file =
download_file(url, None).expect("Error downloading weekly dump file");
diff --git a/src/lib.rs b/src/lib.rs
new file mode 100644
index 0000000..d9b2648
--- /dev/null
+++ b/src/lib.rs
@@ -0,0 +1,7 @@
+pub mod fcc_date;
+pub mod file;
+pub mod load;
+pub mod meta;
+pub mod types;
+
+pub use types::*; \ No newline at end of file