mirror of
https://codeberg.org/icewind/log-archiver.git
synced 2026-06-03 09:34:09 +02:00
global stats and user search
This commit is contained in:
parent
3dc16cd836
commit
cbe97214b6
1 changed files with 10 additions and 1 deletions
11
schema.sql
11
schema.sql
|
|
@ -1,3 +1,5 @@
|
||||||
|
CREATE EXTENSION IF NOT EXISTS pg_trgm WITH SCHEMA public;
|
||||||
|
|
||||||
CREATE TABLE logs_raw (
|
CREATE TABLE logs_raw (
|
||||||
id INTEGER NOT NULL,
|
id INTEGER NOT NULL,
|
||||||
json JSONB NOT NULL,
|
json JSONB NOT NULL,
|
||||||
|
|
@ -149,6 +151,9 @@ CREATE TABLE player_names (
|
||||||
CREATE UNIQUE INDEX player_names_steam_id_name_idx
|
CREATE UNIQUE INDEX player_names_steam_id_name_idx
|
||||||
ON player_names USING BTREE (steam_id, name);
|
ON player_names USING BTREE (steam_id, name);
|
||||||
|
|
||||||
|
CREATE INDEX player_names_search_idx
|
||||||
|
ON player_names USING GIN (name gin_trgm_ops);
|
||||||
|
|
||||||
CREATE OR REPLACE FUNCTION update_player_names() RETURNS trigger AS $$
|
CREATE OR REPLACE FUNCTION update_player_names() RETURNS trigger AS $$
|
||||||
BEGIN
|
BEGIN
|
||||||
INSERT INTO player_names (steam_id, name, count, use_time)
|
INSERT INTO player_names (steam_id, name, count, use_time)
|
||||||
|
|
@ -180,4 +185,8 @@ CREATE MATERIALIZED VIEW user_names AS
|
||||||
GROUP BY steam_id;
|
GROUP BY steam_id;
|
||||||
|
|
||||||
CREATE UNIQUE INDEX user_names_steam_id_idx
|
CREATE UNIQUE INDEX user_names_steam_id_idx
|
||||||
ON user_names USING BTREE (steam_id);
|
ON user_names USING BTREE (steam_id);
|
||||||
|
|
||||||
|
CREATE MATERIALIZED VIEW global_stats AS
|
||||||
|
SELECT SUM(drops) as drops, SUM(ubers) as ubers, SUM(games) as games, SUM(medic_time) as medic_time
|
||||||
|
FROM medic_stats;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue