some bigserials

This commit is contained in:
Robin Appelman 2020-06-18 19:02:17 +02:00
commit 5dfd4c0197
2 changed files with 11 additions and 11 deletions

View file

@ -59,7 +59,7 @@ CREATE INDEX rounds_first_cap_idx
ON rounds USING BTREE (first_cap);
CREATE TABLE events_charge (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
round_id INTEGER NOT NULL REFERENCES rounds(id),
medigun medigun NOT NULL,
time INTEGER NOT NULL,
@ -74,7 +74,7 @@ CREATE INDEX events_charge_steam_id_idx
ON events_charge USING BTREE (steam_id);
CREATE TABLE events_point_cap (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
round_id INTEGER NOT NULL REFERENCES rounds(id),
time INTEGER 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);
CREATE TABLE events_medic_death (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
round_id INTEGER NOT NULL REFERENCES rounds(id),
time INTEGER 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);
CREATE TABLE events_drop (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
round_id INTEGER NOT NULL REFERENCES rounds(id),
time INTEGER NOT NULL,
team team NOT NULL,
@ -114,7 +114,7 @@ CREATE INDEX events_drop_steam_id_idx
ON events_drop USING BTREE (steam_id);
CREATE TABLE events_round_win (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
round_id INTEGER NOT NULL REFERENCES rounds(id),
time INTEGER 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);
CREATE TABLE players (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
log_id INTEGER NOT NULL REFERENCES logs(id),
steam_id BIGINT NOT NULL,
name TEXT NOT NULL,
@ -168,7 +168,7 @@ CREATE INDEX players_steam_id_idx
ON players USING BTREE (steam_id);
CREATE TABLE class_stats (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
player_id INTEGER NOT NULL REFERENCES players(id),
type class_type 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);
CREATE TABLE player_weapon_stats (
id SERIAL PRIMARY KEY,
id BIGSERIAL PRIMARY KEY,
class_stat_id INTEGER NOT NULL REFERENCES class_stats(id),
weapon TEXT NOT NULL,
kills INTEGER NOT NULL,

View file

@ -144,7 +144,7 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
for (steam_id, player) in &log.players {
if let Some(team) = player.team {
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 (\
log_id, steam_id, name, team, kills, deaths, assists,\
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 {
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)\
VALUES($1, $2, $3, $4, $5, $6, $7)\
RETURNING id",
@ -235,7 +235,7 @@ pub async fn store_log(pool: &PgPool, id: i32, log: &NormalizedLog) -> Result<()
sqlx::query!(
"INSERT INTO player_weapon_stats(class_stat_id, weapon, kills, shots, hits, dmg)\
VALUES($1, $2, $3, $4, $5, $6)",
class_stat_id as i32,
class_stat_id,
*weapon,
stats.kills as i32,
stats.shots as i32,