flake reorg

This commit is contained in:
Robin Appelman 2025-05-30 23:27:20 +02:00
commit 6fe18f9771
30 changed files with 146 additions and 214 deletions

View file

@ -3,7 +3,7 @@ name: docker-build
on: on:
push: push:
branches: branches:
- 'master' - "master"
jobs: jobs:
docker: docker:
@ -25,4 +25,4 @@ jobs:
cache-from: type=gha cache-from: type=gha
cache-to: type=gha,mode=max cache-to: type=gha,mode=max
- name: Image digest - name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }} run: echo ${{ steps.docker_build.outputs.digest }}

View file

@ -11,11 +11,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
} }

View file

@ -18,11 +18,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },
@ -64,9 +60,7 @@
"Int4" "Int4"
] ]
}, },
"nullable": [ "nullable": [false]
false
]
}, },
"hash": "253ca64f81921ad7351335d8b47967a4b6831b16d8128a11b40daa63b31f5a4c" "hash": "253ca64f81921ad7351335d8b47967a4b6831b16d8128a11b40daa63b31f5a4c"
} }

View file

@ -10,13 +10,9 @@
} }
], ],
"parameters": { "parameters": {
"Left": [ "Left": ["Int2"]
"Int2"
]
}, },
"nullable": [ "nullable": [null]
null
]
}, },
"hash": "25a688892917d80b8746d77ebbcdfb4652c7047d722c530b4560d6008cdd2b97" "hash": "25a688892917d80b8746d77ebbcdfb4652c7047d722c530b4560d6008cdd2b97"
} }

View file

@ -13,14 +13,7 @@
"Custom": { "Custom": {
"name": "game_mode", "name": "game_mode",
"kind": { "kind": {
"Enum": [ "Enum": ["ultiduo", "4v4", "6v6", "7v7", "9v9", "other"]
"ultiduo",
"4v4",
"6v6",
"7v7",
"9v9",
"other"
]
} }
} }
}, },

View file

@ -4,14 +4,7 @@
"describe": { "describe": {
"columns": [], "columns": [],
"parameters": { "parameters": {
"Left": [ "Left": ["Int8", "Text", "Int4", "Int4", "Int4", "Int4"]
"Int8",
"Text",
"Int4",
"Int4",
"Int4",
"Int4"
]
}, },
"nullable": [] "nullable": []
}, },

View file

@ -11,11 +11,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },
@ -23,12 +19,7 @@
"Custom": { "Custom": {
"name": "medigun", "name": "medigun",
"kind": { "kind": {
"Enum": [ "Enum": ["medigun", "kritzkrieg", "quickfix", "vaccinator"]
"medigun",
"kritzkrieg",
"quickfix",
"vaccinator"
]
} }
} }
}, },

View file

@ -4,12 +4,7 @@
"describe": { "describe": {
"columns": [], "columns": [],
"parameters": { "parameters": {
"Left": [ "Left": ["Int4", "Int8", "Int4", "Int4"]
"Int4",
"Int8",
"Int4",
"Int4"
]
}, },
"nullable": [] "nullable": []
}, },

View file

@ -11,11 +11,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },

View file

@ -11,11 +11,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },

View file

@ -4,10 +4,7 @@
"describe": { "describe": {
"columns": [], "columns": [],
"parameters": { "parameters": {
"Left": [ "Left": ["Int2", "Int4"]
"Int2",
"Int4"
]
}, },
"nullable": [] "nullable": []
}, },

View file

@ -38,9 +38,7 @@
"Int4" "Int4"
] ]
}, },
"nullable": [ "nullable": [false]
false
]
}, },
"hash": "d4d72675d0a0792d14472c6bfc00454791dea1eae933818d168171f818bb7dc9" "hash": "d4d72675d0a0792d14472c6bfc00454791dea1eae933818d168171f818bb7dc9"
} }

View file

@ -18,11 +18,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },
@ -30,11 +26,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },
@ -48,9 +40,7 @@
"Int4" "Int4"
] ]
}, },
"nullable": [ "nullable": [false]
false
]
}, },
"hash": "eab40a01c0df317cdfb97eb4f88884f6776897ec2c2ecb8cae05748c8d087711" "hash": "eab40a01c0df317cdfb97eb4f88884f6776897ec2c2ecb8cae05748c8d087711"
} }

View file

@ -12,9 +12,7 @@
"parameters": { "parameters": {
"Left": [] "Left": []
}, },
"nullable": [ "nullable": [null]
null
]
}, },
"hash": "f4daaeeaaf227491627c0bb54319a5f356028a591fdac2f41ba2dce1c5053d4a" "hash": "f4daaeeaaf227491627c0bb54319a5f356028a591fdac2f41ba2dce1c5053d4a"
} }

View file

@ -11,11 +11,7 @@
"Custom": { "Custom": {
"name": "team", "name": "team",
"kind": { "kind": {
"Enum": [ "Enum": ["blue", "red", "other"]
"blue",
"red",
"other"
]
} }
} }
}, },

View file

@ -9,7 +9,7 @@ name = "log-normalizer"
path = "src/main.rs" path = "src/main.rs"
[dependencies] [dependencies]
sqlx = { version = "0.7.3", default_features = false, features = ["macros", "postgres", "json", "chrono", "runtime-tokio-rustls"] } sqlx = { version = "0.7.3", default-features = false, features = ["macros", "postgres", "json", "chrono", "runtime-tokio-rustls"] }
dotenvy = "0.15.7" dotenvy = "0.15.7"
main_error = "0.1.2" main_error = "0.1.2"
tokio = { version = "1.36.0", features = ["macros", "time", "rt-multi-thread"] } tokio = { version = "1.36.0", features = ["macros", "time", "rt-multi-thread"] }

95
flake.lock generated
View file

@ -1,56 +1,103 @@
{ {
"nodes": { "nodes": {
"flake-utils": { "crane": {
"inputs": {
"systems": "systems"
},
"locked": { "locked": {
"lastModified": 1705309234, "lastModified": 1742394900,
"narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", "narHash": "sha256-vVOAp9ahvnU+fQoKd4SEXB2JG2wbENkpqcwlkIXgUC0=",
"owner": "numtide", "owner": "ipetkov",
"repo": "flake-utils", "repo": "crane",
"rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "rev": "70947c1908108c0c551ddfd73d4f750ff2ea67cd",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "ipetkov",
"repo": "flake-utils", "repo": "crane",
"type": "github" "type": "github"
} }
}, },
"flakelight": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1748263617,
"narHash": "sha256-O1xypYFWzYlfiyO3fUZuzRhYac5DGptP+ZhocY9L5tQ=",
"owner": "nix-community",
"repo": "flakelight",
"rev": "65c783ba2b85910df5a053cb1451e9eb13794c12",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "flakelight",
"type": "github"
}
},
"mill-scale": {
"inputs": {
"crane": "crane",
"flakelight": [
"flakelight"
],
"rust-overlay": "rust-overlay"
},
"locked": {
"lastModified": 1748205441,
"narHash": "sha256-W+UUBT/l1DSTZo5G43494mRNNspJ2i9jW2QELC9JuMQ=",
"ref": "refs/heads/main",
"rev": "dac3b74a89cebbeb21cc6602e4a346604adbee8b",
"revCount": 49,
"type": "git",
"url": "https://codeberg.org/icewind/mill-scale.git"
},
"original": {
"type": "git",
"url": "https://codeberg.org/icewind/mill-scale.git"
}
},
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1707568734, "lastModified": 1748638332,
"narHash": "sha256-PWVdZzc9ZQ6RPfgLCc5pZAV6vhr/UI79u/GBAo/Z2+I=", "narHash": "sha256-s2U9GJgLUohD4sK0w+H/NT+B+m50jxURZNkGXwEbZ4M=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "5cd1bc5c4d702f3ccc26fa93f86d05d5684fe5a3", "rev": "a627748de5a6aa694e9a143df95655b7b52f242c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"id": "nixpkgs", "id": "nixpkgs",
"ref": "release-23.11", "ref": "release-25.05",
"type": "indirect" "type": "indirect"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-utils": "flake-utils", "flakelight": "flakelight",
"mill-scale": "mill-scale",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
}, },
"systems": { "rust-overlay": {
"inputs": {
"nixpkgs": [
"mill-scale",
"flakelight",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1681028828, "lastModified": 1742697269,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", "narHash": "sha256-Lpp0XyAtIl1oGJzNmTiTGLhTkcUjwSkEb0gOiNzYFGM=",
"owner": "nix-systems", "owner": "oxalica",
"repo": "default", "repo": "rust-overlay",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", "rev": "01973c84732f9275c50c5f075dd1f54cc04b3316",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-systems", "owner": "oxalica",
"repo": "default", "repo": "rust-overlay",
"type": "github" "type": "github"
} }
} }

View file

@ -1,54 +1,37 @@
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/release-23.11"; nixpkgs.url = "nixpkgs/release-25.05";
flake-utils.url = "github:numtide/flake-utils"; flakelight = {
url = "github:nix-community/flakelight";
inputs.nixpkgs.follows = "nixpkgs";
};
mill-scale = {
url = "git+https://codeberg.org/icewind/mill-scale.git";
inputs.flakelight.follows = "flakelight";
};
}; };
outputs = { outputs = {mill-scale, ...}:
self, mill-scale ./. {
nixpkgs, withOverlays = [
flake-utils, (import ./nix/overlay.nix)
}: ];
flake-utils.lib.eachDefaultSystem ( extraPaths = [
system: let ./.sqlx
overlays = [ ];
(import ./overlay.nix)
];
pkgs = import nixpkgs {
inherit system overlays;
};
in rec {
packages = rec {
inherit (pkgs) log-normalizer;
default = log-normalizer;
};
devShells.default = pkgs.mkShell { nixosModules = {outputs, ...}: {
nativeBuildInputs = with pkgs; [ default = {
rustc pkgs,
cargo config,
bacon lib,
clippy ...
cargo-edit }: {
cargo-outdated imports = [./nix/module.nix];
cargo-insta config = lib.mkIf config.services.log-normalizer.enable {
sqlx-cli nixpkgs.overlays = [outputs.overlays.default];
]; services.log-normalizer.package = lib.mkDefault pkgs.log-normalizer;
}; };
}
)
// {
overlays.default = import ./overlay.nix;
nixosModules.default = {
pkgs,
config,
lib,
...
}: {
imports = [./module.nix];
config = lib.mkIf config.services.log-normalizer.enable {
nixpkgs.overlays = [self.overlays.default];
services.log-normalizer.package = lib.mkDefault pkgs.log-normalizer;
}; };
}; };
}; };

View file

@ -4,7 +4,7 @@
lib, lib,
}: let }: let
inherit (lib.sources) sourceByRegex; inherit (lib.sources) sourceByRegex;
src = sourceByRegex ./. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"]; src = sourceByRegex ../. ["Cargo.*" "(src|tests|.sqlx)(/.*)?"];
in in
rustPlatform.buildRustPackage rec { rustPlatform.buildRustPackage rec {
pname = "log-normalizer"; pname = "log-normalizer";
@ -15,6 +15,6 @@ in
inherit src; inherit src;
cargoLock = { cargoLock = {
lockFile = ./Cargo.lock; lockFile = ../Cargo.lock;
}; };
} }

View file

@ -65,6 +65,7 @@ pub enum Medigun {
Vaccinator, Vaccinator,
#[serde(other)] #[serde(other)]
#[default] #[default]
#[allow(clippy::enum_variant_names)]
Medigun, Medigun,
} }

View file

@ -2,7 +2,7 @@ pub use crate::data::TeamId;
use crate::data::{GameMode, MapType}; use crate::data::{GameMode, MapType};
use crate::raw::RawLog; use crate::raw::RawLog;
pub use crate::raw::{ pub use crate::raw::{
ChatMessage, ClassNumbers, Event, KillStreak, Player, RoundPlayer, Team, Teams, Uploader, ChatMessage, ClassNumbers, Event, KillStreak, Player, RoundPlayer, Teams, Uploader,
}; };
use chrono::{DateTime, NaiveDateTime, Utc}; use chrono::{DateTime, NaiveDateTime, Utc};
use serde::Deserialize; use serde::Deserialize;
@ -12,6 +12,7 @@ use steamid_ng::SteamID;
#[derive(Debug, Clone, Deserialize)] #[derive(Debug, Clone, Deserialize)]
#[serde(from = "crate::raw::RawLog")] #[serde(from = "crate::raw::RawLog")]
#[allow(dead_code)]
pub struct NormalizedLog { pub struct NormalizedLog {
pub version: u8, pub version: u8,
pub length: u32, pub length: u32,
@ -45,6 +46,7 @@ impl NormalizedLog {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct Info { pub struct Info {
pub map: String, pub map: String,
pub total_length: u32, pub total_length: u32,
@ -96,6 +98,7 @@ impl Info {
} }
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(dead_code)]
pub struct Round { pub struct Round {
pub start_time: u64, pub start_time: u64,
pub winner: Option<TeamId>, pub winner: Option<TeamId>,

View file

@ -1110,11 +1110,7 @@
"players": { "players": {
"STEAM_0:1:741224": { "STEAM_0:1:741224": {
"team": "Blue", "team": "Blue",
"classes": [ "classes": ["scout", "pyro", "heavyweapons"],
"scout",
"pyro",
"heavyweapons"
],
"kills": 24, "kills": 24,
"deaths": 17, "deaths": 17,
"assists": 16, "assists": 16,
@ -1161,9 +1157,7 @@
}, },
"STEAM_0:1:1306478": { "STEAM_0:1:1306478": {
"team": "Red", "team": "Red",
"classes": [ "classes": ["medic"],
"medic"
],
"kills": 0, "kills": 0,
"deaths": 8, "deaths": 8,
"assists": 13, "assists": 13,
@ -1194,10 +1188,7 @@
}, },
"STEAM_0:0:13708020": { "STEAM_0:0:13708020": {
"team": "Blue", "team": "Blue",
"classes": [ "classes": ["soldier", "sniper"],
"soldier",
"sniper"
],
"kills": 18, "kills": 18,
"deaths": 18, "deaths": 18,
"assists": 3, "assists": 3,
@ -1236,9 +1227,7 @@
}, },
"STEAM_0:1:17494569": { "STEAM_0:1:17494569": {
"team": "Blue", "team": "Blue",
"classes": [ "classes": ["demoman"],
"demoman"
],
"kills": 24, "kills": 24,
"deaths": 19, "deaths": 19,
"assists": 8, "assists": 8,
@ -1269,9 +1258,7 @@
}, },
"STEAM_0:0:32905194": { "STEAM_0:0:32905194": {
"team": "Red", "team": "Red",
"classes": [ "classes": ["soldier"],
"soldier"
],
"kills": 22, "kills": 22,
"deaths": 22, "deaths": 22,
"assists": 8, "assists": 8,
@ -1302,9 +1289,7 @@
}, },
"STEAM_0:0:26605378": { "STEAM_0:0:26605378": {
"team": "Blue", "team": "Blue",
"classes": [ "classes": ["soldier"],
"soldier"
],
"kills": 21, "kills": 21,
"deaths": 19, "deaths": 19,
"assists": 7, "assists": 7,
@ -1335,9 +1320,7 @@
}, },
"STEAM_0:0:17635608": { "STEAM_0:0:17635608": {
"team": "Red", "team": "Red",
"classes": [ "classes": ["demoman"],
"demoman"
],
"kills": 29, "kills": 29,
"deaths": 18, "deaths": 18,
"assists": 14, "assists": 14,
@ -1368,9 +1351,7 @@
}, },
"STEAM_0:0:24507746": { "STEAM_0:0:24507746": {
"team": "Blue", "team": "Blue",
"classes": [ "classes": ["medic"],
"medic"
],
"kills": 0, "kills": 0,
"deaths": 12, "deaths": 12,
"assists": 19, "assists": 19,
@ -1401,9 +1382,7 @@
}, },
"STEAM_0:1:19008580": { "STEAM_0:1:19008580": {
"team": "Red", "team": "Red",
"classes": [ "classes": ["soldier"],
"soldier"
],
"kills": 18, "kills": 18,
"deaths": 19, "deaths": 19,
"assists": 9, "assists": 9,
@ -1434,10 +1413,7 @@
}, },
"STEAM_0:0:13159229": { "STEAM_0:0:13159229": {
"team": "Red", "team": "Red",
"classes": [ "classes": ["scout", "pyro"],
"scout",
"pyro"
],
"kills": 20, "kills": 20,
"deaths": 23, "deaths": 23,
"assists": 5, "assists": 5,
@ -1484,10 +1460,7 @@
}, },
"STEAM_0:1:3094211": { "STEAM_0:1:3094211": {
"team": "Red", "team": "Red",
"classes": [ "classes": ["scout", "sniper"],
"scout",
"sniper"
],
"kills": 13, "kills": 13,
"deaths": 24, "deaths": 24,
"assists": 6, "assists": 6,
@ -1526,11 +1499,7 @@
}, },
"STEAM_0:1:40009526": { "STEAM_0:1:40009526": {
"team": "Blue", "team": "Blue",
"classes": [ "classes": ["scout", "heavyweapons", "sniper"],
"scout",
"heavyweapons",
"sniper"
],
"kills": 27, "kills": 27,
"deaths": 17, "deaths": 17,
"assists": 10, "assists": 10,
@ -1986,4 +1955,4 @@
"rows": 4308 "rows": 4308
}, },
"success": true "success": true
} }

View file

@ -3881,4 +3881,4 @@
} }
], ],
"success": true "success": true
} }

View file

@ -1623,4 +1623,4 @@
} }
], ],
"success": true "success": true
} }

View file

@ -2535,4 +2535,4 @@
} }
], ],
"success": true "success": true
} }

View file

@ -1803,4 +1803,4 @@
} }
], ],
"success": true "success": true
} }

View file

@ -2394,4 +2394,4 @@
} }
], ],
"success": true "success": true
} }

View file

@ -2539,4 +2539,4 @@
} }
], ],
"success": true "success": true
} }