mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2026-09-14 08:58:53 +03:00
feat(downloader): download schedule from different source
This commit is contained in:
Vendored
-9
@@ -2,22 +2,13 @@ pub mod schedule;
|
||||
pub mod telegram;
|
||||
pub mod vk_id;
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub mod yandex_cloud;
|
||||
|
||||
pub use self::schedule::ScheduleEnvData;
|
||||
pub use self::telegram::TelegramEnvData;
|
||||
pub use self::vk_id::VkIdEnvData;
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub use self::yandex_cloud::YandexCloudEnvData;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct AppEnv {
|
||||
pub schedule: ScheduleEnvData,
|
||||
pub telegram: TelegramEnvData,
|
||||
pub vk_id: VkIdEnvData,
|
||||
|
||||
#[cfg(not(test))]
|
||||
pub yandex_cloud: YandexCloudEnvData,
|
||||
}
|
||||
|
||||
Vendored
+5
-2
@@ -2,8 +2,10 @@ use std::env;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ScheduleEnvData {
|
||||
/// Public link to the Yandex Disk folder the schedule files are uploaded to.
|
||||
#[cfg(not(test))]
|
||||
pub url: Option<String>,
|
||||
pub yandex_disk_url: String,
|
||||
|
||||
pub auto_update: bool,
|
||||
}
|
||||
|
||||
@@ -11,7 +13,8 @@ impl Default for ScheduleEnvData {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
#[cfg(not(test))]
|
||||
url: env::var("SCHEDULE_INIT_URL").ok(),
|
||||
yandex_disk_url: env::var("SCHEDULE_YANDEX_DISK_URL")
|
||||
.expect("SCHEDULE_YANDEX_DISK_URL must be set"),
|
||||
auto_update: !env::var("SCHEDULE_DISABLE_AUTO_UPDATE")
|
||||
.is_ok_and(|v| v.eq("1") || v.eq("true")),
|
||||
}
|
||||
|
||||
Vendored
-16
@@ -1,16 +0,0 @@
|
||||
use std::env;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct YandexCloudEnvData {
|
||||
pub api_key: String,
|
||||
pub func_id: String,
|
||||
}
|
||||
|
||||
impl Default for YandexCloudEnvData {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
api_key: env::var("YANDEX_CLOUD_API_KEY").expect("YANDEX_CLOUD_API_KEY must be set"),
|
||||
func_id: env::var("YANDEX_CLOUD_FUNC_ID").expect("YANDEX_CLOUD_FUNC_ID must be set"),
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-7
@@ -38,13 +38,8 @@ impl AppState {
|
||||
|
||||
#[cfg(not(test))]
|
||||
{
|
||||
if let Some(url) = &env.schedule.url {
|
||||
providers::EngelsPolytechnicUpdateSource::Url(url.clone())
|
||||
} else {
|
||||
providers::EngelsPolytechnicUpdateSource::GrabFromSite {
|
||||
yandex_api_key: env.yandex_cloud.api_key.clone(),
|
||||
yandex_func_id: env.yandex_cloud.func_id.clone(),
|
||||
}
|
||||
providers::EngelsPolytechnicUpdateSource::YandexDisk {
|
||||
public_url: env.schedule.yandex_disk_url.clone(),
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user