aboutsummaryrefslogtreecommitdiff
path: root/src/filters.rs
diff options
context:
space:
mode:
authorDaniel <kingdread@gmx.de>2020-04-26 11:45:37 +0200
committerDaniel <kingdread@gmx.de>2020-04-26 11:45:37 +0200
commit13053073e3336b8e6ffefd6a056d159239550be7 (patch)
tree63544e8764b55563a48d3f9fd530b0381f42a277 /src/filters.rs
parent3c429432382dfad6d4ac97349c96e4a4eb292089 (diff)
parent9bbd5db2a6caae10f0ab2cf2625fbc34485a4ce9 (diff)
downloadraidgrep-13053073e3336b8e6ffefd6a056d159239550be7.tar.gz
raidgrep-13053073e3336b8e6ffefd6a056d159239550be7.tar.bz2
raidgrep-13053073e3336b8e6ffefd6a056d159239550be7.zip
Merge branch 'new-filters'
The new filter system (includes both the internal rewrite and the command line parsing) is now being included in master. This gives a lot more flexibility.
Diffstat (limited to 'src/filters.rs')
-rw-r--r--src/filters.rs79
1 files changed, 0 insertions, 79 deletions
diff --git a/src/filters.rs b/src/filters.rs
deleted file mode 100644
index cdd8f36..0000000
--- a/src/filters.rs
+++ /dev/null
@@ -1,79 +0,0 @@
-use evtclib::raw::parser::PartialEvtc;
-use evtclib::statistics::gamedata::Boss;
-use evtclib::{Agent, AgentName};
-
-use num_traits::FromPrimitive;
-
-use super::{guilds, LogResult, Opt, SearchField};
-
-use chrono::Datelike;
-
-/// Do filtering based on the character or account name.
-pub fn filter_name(evtc: &PartialEvtc, opt: &Opt) -> bool {
- for player in &evtc.agents {
- let fancy = Agent::from_raw(player);
- if let Ok(AgentName::Player {
- ref account_name,
- ref character_name,
- ..
- }) = fancy.as_ref().map(Agent::name)
- {
- if (opt.field.contains(&SearchField::Account) && opt.expression.is_match(account_name))
- || (opt.field.contains(&SearchField::Character)
- && opt.expression.is_match(character_name))
- {
- return true;
- }
- }
- }
- // Don't throw away the log yet if we are searching for guilds
- opt.field.contains(&SearchField::Guild)
-}
-
-/// Do filtering based on the boss ID.
-pub fn filter_boss(evtc: &PartialEvtc, opt: &Opt) -> bool {
- let boss = Boss::from_u16(evtc.header.combat_id);
- boss.map(|b| opt.bosses.contains(&b)).unwrap_or(true)
-}
-
-/// Do filtering based on the fight outcome.
-pub fn filter_outcome(result: &LogResult, opt: &Opt) -> bool {
- opt.outcome.contains(&result.outcome)
-}
-
-/// Do filtering based on the weekday of the fight.
-pub fn filter_weekday(result: &LogResult, opt: &Opt) -> bool {
- opt.weekdays.contains(&result.time.weekday())
-}
-
-/// Do filtering based on encounter time.
-pub fn filter_time(result: &LogResult, opt: &Opt) -> bool {
- let after_ok = match opt.after {
- Some(time) => time <= result.time,
- None => true,
- };
- let before_ok = match opt.before {
- Some(time) => time >= result.time,
- None => true,
- };
-
- after_ok && before_ok
-}
-
-/// Do filtering based on the guilds.
-pub fn filter_guilds(result: &LogResult, opt: &Opt) -> bool {
- if !opt.guilds {
- return true;
- }
- if !opt.field.contains(&SearchField::Guild) {
- return true;
- }
- result.players.iter().any(|player| {
- let guild = player.guild_id.as_ref().and_then(|id| guilds::lookup(id));
- if let Some(guild) = guild {
- opt.expression.is_match(guild.tag()) || opt.expression.is_match(guild.name())
- } else {
- false
- }
- })
-}