-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jacherr
committed
Jun 28, 2024
1 parent
4ab8f00
commit 2448339
Showing
7 changed files
with
67 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod get_premium_users; | ||
pub mod refresh_web_download_urls; | ||
pub mod reminders; | ||
pub mod top_gg_stats; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use crate::assyst::ThreadSafeAssyst; | ||
use crate::rest::web_media_download::get_web_download_api_urls; | ||
use assyst_common::err; | ||
use tracing::info; | ||
|
||
pub async fn refresh_web_download_urls(assyst: ThreadSafeAssyst) { | ||
info!("Updating web download source URLs"); | ||
|
||
let old = assyst | ||
.rest_cache_handler | ||
.get_web_download_urls() | ||
.iter() | ||
.map(|x| (*(x.clone())).clone()) | ||
.collect::<Vec<_>>(); | ||
|
||
let urls = get_web_download_api_urls(assyst.clone()).await; | ||
|
||
if let Ok(ref new) = urls { | ||
let mut removed = 0; | ||
let mut added = 0; | ||
|
||
println!("{:?}", old); | ||
println!("{:?}", new); | ||
|
||
for url in new { | ||
if !old.contains(url) { | ||
added += 1; | ||
} | ||
} | ||
|
||
for url in old { | ||
if !new.contains(&url) { | ||
removed += 1; | ||
} | ||
} | ||
|
||
info!( | ||
"Updated web download source URLs: got {} urls (removed={removed}, added={added})", | ||
new.len() | ||
); | ||
assyst.rest_cache_handler.set_web_download_urls(new.clone()); | ||
} else if let Err(e) = urls { | ||
err!("Error updating web download source URLs: {}", e.to_string()) | ||
}; | ||
} |