From 98cc712fcd2f4d59e297ae3918e11b5e4a3d2900 Mon Sep 17 00:00:00 2001 From: OMGeeky Date: Mon, 5 Jun 2023 23:14:38 +0200 Subject: [PATCH] misc & rustfmt --- Cargo.toml | 3 ++- src/data/mod.rs | 58 +++++++++++++++++++++---------------------------- src/lib.rs | 7 +++--- 3 files changed, 30 insertions(+), 38 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6c9deee..e8008b9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,8 @@ tracing = { version = "0.1", optional = true } [features] default = [] -tracing = ["dep:tracing", +tracing = [ + "dep:tracing", "google_bigquery_v2/tracing", "google_youtube/tracing", "twitch_data/tracing", diff --git a/src/data/mod.rs b/src/data/mod.rs index a895fb1..6eae909 100644 --- a/src/data/mod.rs +++ b/src/data/mod.rs @@ -15,22 +15,13 @@ pub struct Streamers { pub login: String, #[client] pub client: BigqueryClient, - pub display_name: Option::, - pub watched: Option::, - pub youtube_user: Option::, - pub public_videos_default: Option::, + pub display_name: Option, + pub watched: Option, + pub youtube_user: Option, + pub public_videos_default: Option, + pub youtube_google_ident: Option, } -/*impl<'a> Streamers<'a> { - pub fn get_watched(&self) -> String { - self.login.clone() - } - - fn get_pk_value(&self) -> String { - self.login.clone() - } -}*/ - #[derive(BigDataTableDerive, Debug, Default, Clone)] #[db_name("videos")] pub struct Videos { @@ -40,18 +31,18 @@ pub struct Videos { #[client] pub client: BigqueryClient, - pub title: Option::, - pub description: Option::, - pub bool_test: Option::, - pub user_login: Option::, - pub created_at: Option::>, - pub url: Option::, - pub viewable: Option::, - pub language: Option::, - pub view_count: Option::, - pub video_type: Option::, - pub duration: Option::, - pub thumbnail_url: Option::, + pub title: Option, + pub description: Option, + pub bool_test: Option, + pub user_login: Option, + pub created_at: Option>, + pub url: Option, + pub viewable: Option, + pub language: Option, + pub view_count: Option, + pub video_type: Option, + pub duration: Option, + pub thumbnail_url: Option, } #[derive(BigDataTableDerive, Debug, Default, Clone)] @@ -63,13 +54,13 @@ pub struct VideoMetadata { #[client] pub client: BigqueryClient, - pub backed_up: Option::, - pub total_clips_amount: Option::, - pub parts_backed_up_id: Option::, - pub parts_size: Option::, - pub error: Option::, - pub download_playlist_url: Option::, - pub youtube_playlist_url: Option::, + pub backed_up: Option, + pub total_clips_amount: Option, + pub parts_backed_up_id: Option, + pub parts_size: Option, + pub error: Option, + pub download_playlist_url: Option, + pub youtube_playlist_url: Option, } #[derive(Debug, Default)] @@ -78,6 +69,7 @@ pub struct VideoData { pub metadata: VideoMetadata, pub streamer: Streamers, } + impl VideoData { pub fn from_twitch_video(video: &twitch_data::Video, client: BigqueryClient) -> Result { Ok(Self { diff --git a/src/lib.rs b/src/lib.rs index 90d92f4..b747fe4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -135,8 +135,8 @@ pub async fn start_backup() -> Result<()> { .map_err(|e| anyhow!("{}", e))?; //sleep for an hour - info!("Sleeping for an hour"); - tokio::time::sleep(std::time::Duration::from_secs(60 * 60)).await; + info!("Sleeping for a while"); + tokio::time::sleep(std::time::Duration::from_secs(3 * 60 * 60)).await; //repeat } } @@ -221,8 +221,7 @@ async fn get_not_downloaded_videos_from_db( amount ); let user_login = video.user_login.clone().unwrap().to_lowercase(); - let streamer = - data::Streamers::get_by_pk(client.clone(), &user_login).await; + let streamer = data::Streamers::get_by_pk(client.clone(), &user_login).await; if streamer.is_err() { // .expect(format!("Streamer with login not found: {}", user_login).as_str()); warn!("Streamer with login not found: {}", user_login);