From 2e2a6037ef81b7ed0f6cba34e540659cf03ec85f Mon Sep 17 00:00:00 2001 From: Zefanja Jobse Date: Wed, 30 Aug 2023 11:47:04 +0200 Subject: [PATCH] add isOfficial column and fix fields in influx --- src/connectors/influx_db.rs | 6 +++--- src/connectors/quest_db.rs | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/connectors/influx_db.rs b/src/connectors/influx_db.rs index d40e313..54d331b 100644 --- a/src/connectors/influx_db.rs +++ b/src/connectors/influx_db.rs @@ -324,11 +324,11 @@ pub fn build_server_data_point( let mut data_point = DataPoint::builder(frontend_game_name); data_point = match !server_info.guid.is_empty() { - true => data_point.tag("guid", &server_info.guid), + true => data_point.field("guid", server_info.guid.clone()), false => data_point, }; data_point = match !server_info.game_id.is_empty() { - true => data_point.tag("gameId", &server_info.game_id), + true => data_point.field("gameId", server_info.game_id.clone()), false => data_point, }; data_point = match server_info.is_official { @@ -339,8 +339,8 @@ pub fn build_server_data_point( data_point .tag("platform", platform) .tag("region", region) - .tag("serverName", &server_info.name) .tag("type", data_type) + .field("serverName", server_info.name.clone()) .field(field, *amount) .build() } diff --git a/src/connectors/quest_db.rs b/src/connectors/quest_db.rs index 8fd5ca4..ae82330 100644 --- a/src/connectors/quest_db.rs +++ b/src/connectors/quest_db.rs @@ -1,5 +1,5 @@ -use questdb::ingress::{Buffer, SenderBuilder}; use crate::structs::{results, server_info}; +use questdb::ingress::{Buffer, SenderBuilder}; use std::collections::HashMap; // let mut sender = SenderBuilder::new("167.86.108.125", 9009).connect()?; @@ -38,6 +38,10 @@ pub fn push_server( true => buffer.column_str("map", server_info.map)?, false => buffer, }; + buffer = match server_info.is_official { + Some(result) => buffer.column_bool("isOfficial", result)?, + None => buffer, + }; buffer .column_i64("soldierAmount", server_info.soldiers)? @@ -49,7 +53,6 @@ pub fn push_server( Ok(()) } - // pub fn push_totals(global_result: &results::RegionResult) -> anyhow::Result<()> { // let mut quest_sender = SenderBuilder::new("167.86.108.125", 9009).connect()?; // let buffer = &mut Buffer::new(); @@ -210,6 +213,6 @@ pub fn push_server( // } // } // } - + // Ok(()) -// } \ No newline at end of file +// }