feat: allow for overlapping festivals
This commit is contained in:
parent
1555a94656
commit
51d5904ffd
1 changed files with 17 additions and 17 deletions
|
@ -107,7 +107,7 @@ async fn update_icon_main(ctx: Arc<Context>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FestivalData{
|
struct FestivalData{
|
||||||
current: Option<String>,
|
current: Vec<String>,
|
||||||
exclusions: Vec<String>,
|
exclusions: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ fn get_festival(config_toml: &ConfigToml)-> FestivalData {
|
||||||
let year = today.year();
|
let year = today.year();
|
||||||
|
|
||||||
let mut result = FestivalData {
|
let mut result = FestivalData {
|
||||||
current: None,
|
current: vec![],
|
||||||
exclusions: vec![],
|
exclusions: vec![],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@ fn get_festival(config_toml: &ConfigToml)-> FestivalData {
|
||||||
if (day >= festival.start.day && day <= festival.end.day) &&
|
if (day >= festival.start.day && day <= festival.end.day) &&
|
||||||
(month >= festival.start.month && month <= festival.end.month ) {
|
(month >= festival.start.month && month <= festival.end.month ) {
|
||||||
if festival.start.year == 0 || festival.end.year == 0 {
|
if festival.start.year == 0 || festival.end.year == 0 {
|
||||||
result.current = Some(festival.name.to_owned());
|
result.current.push(festival.name.to_owned());
|
||||||
} else if (year >= festival.start.year && year <= festival.end.year) {
|
} else if (year >= festival.start.year && year <= festival.end.year) {
|
||||||
result.current = Some(festival.name.to_owned());
|
result.current.push(festival.name.to_owned());
|
||||||
}
|
}
|
||||||
} else if !festival.all_year {
|
} else if !festival.all_year {
|
||||||
result.exclusions.push(festival.name.to_owned());
|
result.exclusions.push(festival.name.to_owned());
|
||||||
|
@ -279,27 +279,27 @@ fn get_logos(config: &Config, config_toml: &ConfigToml) -> Vec<LogoData> {
|
||||||
fn logos_filter(festival_data: &FestivalData, existing: Vec<LogoData>) -> Vec<LogoData>{
|
fn logos_filter(festival_data: &FestivalData, existing: Vec<LogoData>) -> Vec<LogoData>{
|
||||||
let mut filtered: Vec<LogoData> = vec![];
|
let mut filtered: Vec<LogoData> = vec![];
|
||||||
|
|
||||||
for logo in existing {
|
'outer: for logo in existing {
|
||||||
let name_lowercase0 = logo.name.to_ascii_lowercase();
|
let name_lowercase0 = logo.name.to_ascii_lowercase();
|
||||||
let name_lowercase = name_lowercase0.to_str().unwrap_or_default();
|
let name_lowercase = name_lowercase0.to_str().unwrap_or_default();
|
||||||
|
|
||||||
// if its a current festival filter based on it
|
// if its a current festival filter based on it
|
||||||
if let Some(x) = &festival_data.current {
|
for festival in &festival_data.current {
|
||||||
if name_lowercase.contains(x) {
|
if name_lowercase.contains(festival) {
|
||||||
filtered.push(logo);
|
filtered.push(logo);
|
||||||
|
continue 'outer;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
// else filter using the excluded ones
|
// else filter using the excluded ones
|
||||||
let mut excluded = false;
|
let mut excluded = false;
|
||||||
for festival in &festival_data.exclusions {
|
for festival in &festival_data.exclusions {
|
||||||
if name_lowercase.contains(festival) {
|
if name_lowercase.contains(festival) {
|
||||||
excluded = true;
|
excluded = true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if !excluded {
|
if !excluded {
|
||||||
filtered.push(logo);
|
filtered.push(logo);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue