Skip to content

Commit 06436b4

Browse files
committed
perf(database): remove players table because is is unnecessary
1 parent 53f8100 commit 06436b4

2 files changed

Lines changed: 3 additions & 17 deletions

File tree

migrations/0002_remove_players.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
ALTER TABLE player_history DROP CONSTRAINT IF EXISTS player_history_uuid_fkey;
2+
DROP TABLE IF EXISTS players;
3+
CREATE INDEX IF NOT EXISTS idx_player_history_uuid ON player_history(uuid);

src/database/server.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,6 @@ pub async fn insert_servers(results: &Vec<(ServerInfo, ServerHistory)>) -> Resul
7373

7474
pub async fn insert_players(player_data: &Vec<(Player, PlayerHistory)>, tx: &mut Transaction<'_, Postgres>) -> Result<(), sqlx::Error> {
7575
for (player, history) in player_data {
76-
sqlx::query(
77-
r#"
78-
INSERT INTO players (uuid, username, discovered, last_seen)
79-
VALUES ($1, $2, $3, $4)
80-
ON CONFLICT (uuid)
81-
DO UPDATE SET
82-
last_seen = EXCLUDED.last_seen,
83-
username = EXCLUDED.username
84-
"#
85-
)
86-
.bind(&player.uuid)
87-
.bind(&player.username)
88-
.bind(player.discovered)
89-
.bind(player.last_seen)
90-
.execute(&mut **tx)
91-
.await?;
92-
9376
sqlx::query(
9477
r#"
9578
INSERT INTO player_history (uuid, username, server_id, seen)

0 commit comments

Comments
 (0)