Add world type to osrs_world_players metric
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
196b8cef41
commit
7e9232b3f3
1 changed files with 58 additions and 2 deletions
|
@ -49,6 +49,7 @@ impl Display for WorldLocation {
|
|||
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub enum WorldType {
|
||||
FreeToPlay,
|
||||
Members,
|
||||
PVP,
|
||||
Bounty,
|
||||
|
@ -92,6 +93,28 @@ impl<'de> Deserialize<'de> for WorldType {
|
|||
}
|
||||
}
|
||||
|
||||
impl Display for WorldType {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
WorldType::FreeToPlay => write!(f, "FreeToPlay"),
|
||||
WorldType::Members => write!(f, "Members"),
|
||||
WorldType::PVP => write!(f, "PVP"),
|
||||
WorldType::Bounty => write!(f, "Bounty"),
|
||||
WorldType::PVPArena => write!(f, "PVPArena"),
|
||||
WorldType::SkillTotal => write!(f, "SkillTotal"),
|
||||
WorldType::QuestSpeedrunning => write!(f, "QuestSpeedrunning"),
|
||||
WorldType::HighRisk => write!(f, "HighRisk"),
|
||||
WorldType::LastManStanding => write!(f, "LastManStanding"),
|
||||
WorldType::NoSaveMode => write!(f, "NoSaveMode"),
|
||||
WorldType::Tournament => write!(f, "Tournament"),
|
||||
WorldType::FreshStartWorld => write!(f, "FreshStartWorld"),
|
||||
WorldType::Deadman => write!(f, "Deadman"),
|
||||
WorldType::Seasonal => write!(f, "Seasonal"),
|
||||
WorldType::Unknown => write!(f, "Unknown"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
pub struct World {
|
||||
pub id: i16,
|
||||
|
@ -104,12 +127,12 @@ pub struct World {
|
|||
|
||||
impl PromMetric for World {
|
||||
fn to_metric_string(&self) -> String {
|
||||
//"player_count{id=\"301\",location=\"Germany\,"isMembers=\"true\"} 123"
|
||||
format!(
|
||||
"osrs_world_players{{id=\"{}\",location=\"{}\",isMembers=\"{:?}\"}} {}",
|
||||
"osrs_world_players{{id=\"{}\",location=\"{}\",isMembers=\"{:?}\",type=\"{}\"}} {}",
|
||||
self.id,
|
||||
self.location,
|
||||
self.is_members(),
|
||||
self.world_type(),
|
||||
self.players
|
||||
)
|
||||
}
|
||||
|
@ -119,6 +142,39 @@ impl World {
|
|||
pub fn is_members(&self) -> bool {
|
||||
self.types.contains(&WorldType::Members)
|
||||
}
|
||||
pub fn world_type(&self) -> WorldType {
|
||||
if self.types.len() == 0 {
|
||||
WorldType::FreeToPlay
|
||||
} else if self.types.contains(&WorldType::QuestSpeedrunning) {
|
||||
WorldType::QuestSpeedrunning
|
||||
} else if self.types.contains(&WorldType::HighRisk) {
|
||||
WorldType::HighRisk
|
||||
} else if self.types.contains(&WorldType::LastManStanding) {
|
||||
WorldType::LastManStanding
|
||||
} else if self.types.contains(&WorldType::Bounty) {
|
||||
WorldType::Bounty
|
||||
} else if self.types.contains(&WorldType::PVP) {
|
||||
WorldType::PVP
|
||||
} else if self.types.contains(&WorldType::PVPArena) {
|
||||
WorldType::PVPArena
|
||||
} else if self.types.contains(&WorldType::NoSaveMode) {
|
||||
WorldType::NoSaveMode
|
||||
} else if self.types.contains(&WorldType::Deadman) {
|
||||
WorldType::Deadman
|
||||
} else if self.types.contains(&WorldType::Tournament) {
|
||||
WorldType::Tournament
|
||||
} else if self.types.contains(&WorldType::SkillTotal) {
|
||||
WorldType::SkillTotal
|
||||
} else if self.types.contains(&WorldType::FreshStartWorld) {
|
||||
WorldType::FreshStartWorld
|
||||
} else if self.types.contains(&WorldType::Seasonal) {
|
||||
WorldType::Seasonal
|
||||
} else if self.is_members() {
|
||||
WorldType::Members
|
||||
} else {
|
||||
WorldType::Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn get_player_count() -> eyre::Result<Vec<World>> {
|
||||
|
|
Loading…
Reference in a new issue