mirror of
https://codeberg.org/icewind/log-normalizer.git
synced 2026-06-03 13:54:11 +02:00
some bigserials
This commit is contained in:
parent
45e32f5601
commit
5dfd4c0197
2 changed files with 11 additions and 11 deletions
16
schema.sql
16
schema.sql
|
|
@ -59,7 +59,7 @@ CREATE INDEX rounds_first_cap_idx
|
||||||
ON rounds USING BTREE (first_cap);
|
ON rounds USING BTREE (first_cap);
|
||||||
|
|
||||||
CREATE TABLE events_charge (
|
CREATE TABLE events_charge (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
||||||
medigun medigun NOT NULL,
|
medigun medigun NOT NULL,
|
||||||
time INTEGER NOT NULL,
|
time INTEGER NOT NULL,
|
||||||
|
|
@ -74,7 +74,7 @@ CREATE INDEX events_charge_steam_id_idx
|
||||||
ON events_charge USING BTREE (steam_id);
|
ON events_charge USING BTREE (steam_id);
|
||||||
|
|
||||||
CREATE TABLE events_point_cap (
|
CREATE TABLE events_point_cap (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
||||||
time INTEGER NOT NULL,
|
time INTEGER NOT NULL,
|
||||||
team team NOT NULL,
|
team team NOT NULL,
|
||||||
|
|
@ -85,7 +85,7 @@ CREATE INDEX events_point_cap_round_id_idx
|
||||||
ON events_point_cap USING BTREE (round_id);
|
ON events_point_cap USING BTREE (round_id);
|
||||||
|
|
||||||
CREATE TABLE events_medic_death (
|
CREATE TABLE events_medic_death (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
||||||
time INTEGER NOT NULL,
|
time INTEGER NOT NULL,
|
||||||
team team NOT NULL,
|
team team NOT NULL,
|
||||||
|
|
@ -100,7 +100,7 @@ CREATE INDEX events_medic_death_steam_id_idx
|
||||||
ON events_medic_death USING BTREE (steam_id);
|
ON events_medic_death USING BTREE (steam_id);
|
||||||
|
|
||||||
CREATE TABLE events_drop (
|
CREATE TABLE events_drop (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
||||||
time INTEGER NOT NULL,
|
time INTEGER NOT NULL,
|
||||||
team team NOT NULL,
|
team team NOT NULL,
|
||||||
|
|
@ -114,7 +114,7 @@ CREATE INDEX events_drop_steam_id_idx
|
||||||
ON events_drop USING BTREE (steam_id);
|
ON events_drop USING BTREE (steam_id);
|
||||||
|
|
||||||
CREATE TABLE events_round_win (
|
CREATE TABLE events_round_win (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
round_id INTEGER NOT NULL REFERENCES rounds(id),
|
||||||
time INTEGER NOT NULL,
|
time INTEGER NOT NULL,
|
||||||
team team NOT NULL
|
team team NOT NULL
|
||||||
|
|
@ -124,7 +124,7 @@ CREATE UNIQUE INDEX events_round_win_round_id_idx
|
||||||
ON events_round_win USING BTREE (round_id);
|
ON events_round_win USING BTREE (round_id);
|
||||||
|
|
||||||
CREATE TABLE players (
|
CREATE TABLE players (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
log_id INTEGER NOT NULL REFERENCES logs(id),
|
log_id INTEGER NOT NULL REFERENCES logs(id),
|
||||||
steam_id BIGINT NOT NULL,
|
steam_id BIGINT NOT NULL,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
|
|
@ -168,7 +168,7 @@ CREATE INDEX players_steam_id_idx
|
||||||
ON players USING BTREE (steam_id);
|
ON players USING BTREE (steam_id);
|
||||||
|
|
||||||
CREATE TABLE class_stats (
|
CREATE TABLE class_stats (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
player_id INTEGER NOT NULL REFERENCES players(id),
|
player_id INTEGER NOT NULL REFERENCES players(id),
|
||||||
type class_type NOT NULL,
|
type class_type NOT NULL,
|
||||||
time INTEGER NOT NULL,
|
time INTEGER NOT NULL,
|
||||||
|
|
@ -185,7 +185,7 @@ CREATE UNIQUE INDEX class_stats_player_id_type_idx
|
||||||
ON class_stats USING BTREE (player_id, type);
|
ON class_stats USING BTREE (player_id, type);
|
||||||
|
|
||||||
CREATE TABLE player_weapon_stats (
|
CREATE TABLE player_weapon_stats (
|
||||||
id SERIAL PRIMARY KEY,
|
id BIGSERIAL PRIMARY KEY,
|
||||||
class_stat_id INTEGER NOT NULL REFERENCES class_stats(id),
|
class_stat_id INTEGER NOT NULL REFERENCES class_stats(id),
|
||||||
weapon TEXT NOT NULL,
|
weapon TEXT NOT NULL,
|
||||||
kills INTEGER NOT NULL,
|
kills INTEGER NOT NULL,
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
|
||||||
for (steam_id, player) in &log.players {
|
for (steam_id, player) in &log.players {
|
||||||
if let Some(team) = player.team {
|
if let Some(team) = player.team {
|
||||||
let kills = log.class_kills.get(steam_id).cloned().unwrap_or_default();
|
let kills = log.class_kills.get(steam_id).cloned().unwrap_or_default();
|
||||||
let player_id: i32 = sqlx::query!(
|
let player_id: i64 = sqlx::query!(
|
||||||
"INSERT INTO players (\
|
"INSERT INTO players (\
|
||||||
log_id, steam_id, name, team, kills, deaths, assists,\
|
log_id, steam_id, name, team, kills, deaths, assists,\
|
||||||
suicides, dmg, damage_taken, ubers, medigun_ubers,\
|
suicides, dmg, damage_taken, ubers, medigun_ubers,\
|
||||||
|
|
@ -215,7 +215,7 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
|
||||||
|
|
||||||
for class in &player.class_stats {
|
for class in &player.class_stats {
|
||||||
if class.class != Class::Unknown {
|
if class.class != Class::Unknown {
|
||||||
let class_stat_id: i32 = sqlx::query!(
|
let class_stat_id: i64 = sqlx::query!(
|
||||||
"INSERT INTO class_stats(player_id, type, time, kills, deaths, assists, dmg)\
|
"INSERT INTO class_stats(player_id, type, time, kills, deaths, assists, dmg)\
|
||||||
VALUES($1, $2, $3, $4, $5, $6, $7)\
|
VALUES($1, $2, $3, $4, $5, $6, $7)\
|
||||||
RETURNING id",
|
RETURNING id",
|
||||||
|
|
@ -235,7 +235,7 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
|
||||||
sqlx::query!(
|
sqlx::query!(
|
||||||
"INSERT INTO player_weapon_stats(class_stat_id, weapon, kills, shots, hits, dmg)\
|
"INSERT INTO player_weapon_stats(class_stat_id, weapon, kills, shots, hits, dmg)\
|
||||||
VALUES($1, $2, $3, $4, $5, $6)",
|
VALUES($1, $2, $3, $4, $5, $6)",
|
||||||
class_stat_id as i32,
|
class_stat_id,
|
||||||
*weapon,
|
*weapon,
|
||||||
stats.kills as i32,
|
stats.kills as i32,
|
||||||
stats.shots as i32,
|
stats.shots as i32,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue