Skip to content

Commit

Permalink
Merge pull request #33 from w3champions/override-flo-tv-delay
Browse files Browse the repository at this point in the history
Add `flo_tv_delay_override_secs` to game.
  • Loading branch information
fluxxu authored Nov 1, 2023
2 parents 3a36c81 + 48488b3 commit f6a32c9
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 17 deletions.
7 changes: 6 additions & 1 deletion binaries/flo-stats-service/src/graphql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl MutationRoot {
return Err(Error::new("Can not stream a private game."));
}

let delay_secs = if let Some(value) = delay_secs {
let mut delay_secs = if let Some(value) = delay_secs {
if data.is_admin {
value as i64
} else {
Expand All @@ -53,6 +53,11 @@ impl MutationRoot {
180
}
};

if let Some(secs) = game.flo_tv_delay_override_secs.clone() {
delay_secs = secs as i64
}

let delay_secs = if delay_secs == 0 {
None
} else {
Expand Down
8 changes: 8 additions & 0 deletions crates/controller/src/game/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ pub fn create(conn: &DbConn, params: CreateGameParams) -> Result<Game> {
node_id: None,
mask_player_names: false,
enable_ping_equalizer: false,
flo_tv_delay_override_secs: None,
};

let row = conn.transaction(|| -> Result<_> {
Expand All @@ -232,6 +233,7 @@ pub struct CreateGameAsBotParams {
pub slots: Vec<CreateGameSlot>,
pub mask_player_names: bool,
pub enable_ping_equalizer: bool,
pub flo_tv_delay_override_secs: Option<i32>,
}

/// Creates a full game and lock it
Expand Down Expand Up @@ -349,6 +351,7 @@ pub fn create_as_bot(
node_id: Some(params.node_id),
mask_player_names: params.mask_player_names,
enable_ping_equalizer: params.enable_ping_equalizer,
flo_tv_delay_override_secs: None,
};

let row = conn.transaction(|| -> Result<_> {
Expand Down Expand Up @@ -1014,6 +1017,7 @@ pub struct GameRowWithRelated {
pub mask_player_names: bool,
pub game_version: Option<String>,
pub enable_ping_equalizer: bool,
pub flo_tv_delay_override_secs: Option<i32>,
}

pub(crate) type GameRowWithRelatedColumns = (
Expand All @@ -1036,6 +1040,7 @@ pub(crate) type GameRowWithRelatedColumns = (
game::dsl::mask_player_names,
game::dsl::game_version,
game::dsl::enable_ping_equalizer,
game::dsl::flo_tv_delay_override_secs,
);

impl GameRowWithRelated {
Expand All @@ -1060,6 +1065,7 @@ impl GameRowWithRelated {
game::dsl::mask_player_names,
game::dsl::game_version,
game::dsl::enable_ping_equalizer,
game::dsl::flo_tv_delay_override_secs,
)
}

Expand All @@ -1086,6 +1092,7 @@ impl GameRowWithRelated {
mask_player_names: self.mask_player_names,
game_version: self.game_version,
enable_ping_equalizer: self.enable_ping_equalizer,
flo_tv_delay_override_secs: self.flo_tv_delay_override_secs,
})
}
}
Expand All @@ -1105,6 +1112,7 @@ pub struct GameInsert<'a> {
pub node_id: Option<i32>,
pub mask_player_names: bool,
pub enable_ping_equalizer: bool,
pub flo_tv_delay_override_secs: Option<i32>,
}

#[derive(Debug, Insertable)]
Expand Down
1 change: 1 addition & 0 deletions crates/controller/src/game/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ pub struct Game {
pub mask_player_names: bool,
pub game_version: Option<String>,
pub enable_ping_equalizer: bool,
pub flo_tv_delay_override_secs: Option<i32>,
}

impl S2ProtoPack<flo_net::proto::flo_connect::GameInfo> for Game {
Expand Down
33 changes: 18 additions & 15 deletions crates/controller/src/schema.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
table! {
// @generated automatically by Diesel CLI.

diesel::table! {
api_client (id) {
id -> Int4,
name -> Text,
Expand All @@ -7,7 +9,7 @@ table! {
}
}

table! {
diesel::table! {
game (id) {
id -> Int4,
name -> Text,
Expand All @@ -29,10 +31,11 @@ table! {
mask_player_names -> Bool,
game_version -> Nullable<Text>,
enable_ping_equalizer -> Bool,
flo_tv_delay_override_secs -> Nullable<Int4>,
}
}

table! {
diesel::table! {
game_used_slot (id) {
id -> Int4,
game_id -> Int4,
Expand All @@ -52,15 +55,15 @@ table! {
}
}

table! {
diesel::table! {
map_checksum (id) {
id -> Int4,
sha1 -> Text,
checksum -> Bytea,
}
}

table! {
diesel::table! {
node (id) {
id -> Int4,
name -> Text,
Expand All @@ -74,7 +77,7 @@ table! {
}
}

table! {
diesel::table! {
player (id) {
id -> Int4,
name -> Text,
Expand All @@ -88,7 +91,7 @@ table! {
}
}

table! {
diesel::table! {
player_ban (id) {
id -> Int4,
player_id -> Int4,
Expand All @@ -98,7 +101,7 @@ table! {
}
}

table! {
diesel::table! {
player_mute (id) {
id -> Int4,
player_id -> Int4,
Expand All @@ -107,14 +110,14 @@ table! {
}
}

joinable!(game -> node (node_id));
joinable!(game -> player (created_by));
joinable!(game_used_slot -> game (game_id));
joinable!(game_used_slot -> player (player_id));
joinable!(player -> api_client (api_client_id));
joinable!(player_ban -> player (player_id));
diesel::joinable!(game -> node (node_id));
diesel::joinable!(game -> player (created_by));
diesel::joinable!(game_used_slot -> game (game_id));
diesel::joinable!(game_used_slot -> player (player_id));
diesel::joinable!(player -> api_client (api_client_id));
diesel::joinable!(player_ban -> player (player_id));

allow_tables_to_appear_in_same_query!(
diesel::allow_tables_to_appear_in_same_query!(
api_client,
game,
game_used_slot,
Expand Down
1 change: 1 addition & 0 deletions crates/observer-edge/src/game/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ pub struct Game {
pub mask_player_names: bool,
pub is_private: bool,
pub is_live: bool,
pub flo_tv_delay_override_secs: Option<i32>,
}

#[derive(Debug, S2ProtoUnpack, SimpleObject)]
Expand Down
2 changes: 2 additions & 0 deletions crates/observer-edge/src/game/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ pub struct GameSnapshot {
pub mask_player_names: bool,
pub is_private: bool,
pub is_live: bool,
pub flo_tv_delay_override_secs: Option<i32>,
}

impl GameSnapshot {
Expand Down Expand Up @@ -204,6 +205,7 @@ impl GameSnapshot {
mask_player_names: game.mask_player_names,
is_private: game.is_private,
is_live: game.is_live,
flo_tv_delay_override_secs: game.flo_tv_delay_override_secs,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion deps/flo-grpc
2 changes: 2 additions & 0 deletions migrations/2023-11-01-135902_game-flo-tv-delay/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "game"
drop column flo_tv_delay_override_secs;
2 changes: 2 additions & 0 deletions migrations/2023-11-01-135902_game-flo-tv-delay/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table "game"
add column flo_tv_delay_override_secs integer;

0 comments on commit f6a32c9

Please sign in to comment.