--- /dev/null
+CREATE TABLE xonstat.player_game_nonparticipants
+(
+ player_game_nonparticipants_id bigserial NOT NULL,
+ player_id integer NOT NULL,
+ game_id bigint NOT NULL,
+ nick character varying(128),
+ stripped_nick character varying(128),
+ alivetime interval,
+ score integer,
+ create_dt timestamp without time zone NOT NULL DEFAULT (current_timestamp at time zone 'UTC'),
+ CONSTRAINT player_game_nonparticipants_pk PRIMARY KEY (player_game_nonparticipants_id),
+ CONSTRAINT player_game_nonparticipants_fk001 FOREIGN KEY (player_id)
+ REFERENCES xonstat.players (player_id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION,
+ CONSTRAINT player_game_nonparticipants_fk002 FOREIGN KEY (game_id)
+ REFERENCES xonstat.games (game_id) MATCH SIMPLE
+ ON UPDATE NO ACTION ON DELETE NO ACTION
+)
+WITH (
+ OIDS=FALSE
+);
+
+CREATE INDEX player_game_nonparticipant_ix01 on player_game_nonparticipantss(create_dt);
+CREATE INDEX player_game_nonparticipant_ix02 on player_game_nonparticipantss(game_id);
+CREATE INDEX player_game_nonparticipant_ix03 on player_game_nonparticipantss(player_id);
+ALTER TABLE xonstat.player_game_stats OWNER TO xonstat;
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2020q4 (
+ CHECK ( create_dt >= DATE '2020-10-01' AND create_dt < DATE '2021-01-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2020q4_ix001 on player_game_nonparticipants_2020q4(create_dt);
+CREATE INDEX player_game_nonparticipants_2020q4_ix002 on player_game_nonparticipants_2020q4(game_id);
+CREATE INDEX player_game_nonparticipants_2020q4_ix003 on player_game_nonparticipants_2020q4(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2021q1 (
+ CHECK ( create_dt >= DATE '2021-01-01' AND create_dt < DATE '2021-04-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2021q1_ix001 on player_game_nonparticipants_2021q1(create_dt);
+CREATE INDEX player_game_nonparticipants_2021q1_ix002 on player_game_nonparticipants_2021q1(game_id);
+CREATE INDEX player_game_nonparticipants_2021q1_ix003 on player_game_nonparticipants_2021q1(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2021q2 (
+ CHECK ( create_dt >= DATE '2021-04-01' AND create_dt < DATE '2021-07-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2021q2_ix001 on player_game_nonparticipants_2021q2(create_dt);
+CREATE INDEX player_game_nonparticipants_2021q2_ix002 on player_game_nonparticipants_2021q2(game_id);
+CREATE INDEX player_game_nonparticipants_2021q2_ix003 on player_game_nonparticipants_2021q2(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2021q3 (
+ CHECK ( create_dt >= DATE '2021-07-01' AND create_dt < DATE '2021-10-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2021q3_ix001 on player_game_nonparticipants_2021q3(create_dt);
+CREATE INDEX player_game_nonparticipants_2021q3_ix002 on player_game_nonparticipants_2021q3(game_id);
+CREATE INDEX player_game_nonparticipants_2021q3_ix003 on player_game_nonparticipants_2021q3(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2021q4 (
+ CHECK ( create_dt >= DATE '2021-10-01' AND create_dt < DATE '2022-01-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2021q4_ix001 on player_game_nonparticipants_2021q4(create_dt);
+CREATE INDEX player_game_nonparticipants_2021q4_ix002 on player_game_nonparticipants_2021q4(game_id);
+CREATE INDEX player_game_nonparticipants_2021q4_ix003 on player_game_nonparticipants_2021q4(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2022q1 (
+ CHECK ( create_dt >= DATE '2022-01-01' AND create_dt < DATE '2022-04-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2022q1_ix001 on player_game_nonparticipants_2022q1(create_dt);
+CREATE INDEX player_game_nonparticipants_2022q1_ix002 on player_game_nonparticipants_2022q1(game_id);
+CREATE INDEX player_game_nonparticipants_2022q1_ix003 on player_game_nonparticipants_2022q1(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2022q2 (
+ CHECK ( create_dt >= DATE '2022-04-01' AND create_dt < DATE '2022-07-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2022q2_ix001 on player_game_nonparticipants_2022q2(create_dt);
+CREATE INDEX player_game_nonparticipants_2022q2_ix002 on player_game_nonparticipants_2022q2(game_id);
+CREATE INDEX player_game_nonparticipants_2022q2_ix003 on player_game_nonparticipants_2022q2(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2022q3 (
+ CHECK ( create_dt >= DATE '2022-07-01' AND create_dt < DATE '2022-10-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2022q3_ix001 on player_game_nonparticipants_2022q3(create_dt);
+CREATE INDEX player_game_nonparticipants_2022q3_ix002 on player_game_nonparticipants_2022q3(game_id);
+CREATE INDEX player_game_nonparticipants_2022q3_ix003 on player_game_nonparticipants_2022q3(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2022q4 (
+ CHECK ( create_dt >= DATE '2022-10-01' AND create_dt < DATE '2023-01-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2022q4_ix001 on player_game_nonparticipants_2022q4(create_dt);
+CREATE INDEX player_game_nonparticipants_2022q4_ix002 on player_game_nonparticipants_2022q4(game_id);
+CREATE INDEX player_game_nonparticipants_2022q4_ix003 on player_game_nonparticipants_2022q4(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2023q1 (
+ CHECK ( create_dt >= DATE '2023-01-01' AND create_dt < DATE '2023-04-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2023q1_ix001 on player_game_nonparticipants_2023q1(create_dt);
+CREATE INDEX player_game_nonparticipants_2023q1_ix002 on player_game_nonparticipants_2023q1(game_id);
+CREATE INDEX player_game_nonparticipants_2023q1_ix003 on player_game_nonparticipants_2023q1(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2023q2 (
+ CHECK ( create_dt >= DATE '2023-04-01' AND create_dt < DATE '2023-07-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2023q2_ix001 on player_game_nonparticipants_2023q2(create_dt);
+CREATE INDEX player_game_nonparticipants_2023q2_ix002 on player_game_nonparticipants_2023q2(game_id);
+CREATE INDEX player_game_nonparticipants_2023q2_ix003 on player_game_nonparticipants_2023q2(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2023q3 (
+ CHECK ( create_dt >= DATE '2023-07-01' AND create_dt < DATE '2023-10-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2023q3_ix001 on player_game_nonparticipants_2023q3(create_dt);
+CREATE INDEX player_game_nonparticipants_2023q3_ix002 on player_game_nonparticipants_2023q3(game_id);
+CREATE INDEX player_game_nonparticipants_2023q3_ix003 on player_game_nonparticipants_2023q3(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2023q4 (
+ CHECK ( create_dt >= DATE '2023-10-01' AND create_dt < DATE '2024-01-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2023q4_ix001 on player_game_nonparticipants_2023q4(create_dt);
+CREATE INDEX player_game_nonparticipants_2023q4_ix002 on player_game_nonparticipants_2023q4(game_id);
+CREATE INDEX player_game_nonparticipants_2023q4_ix003 on player_game_nonparticipants_2023q4(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2024q1 (
+ CHECK ( create_dt >= DATE '2024-01-01' AND create_dt < DATE '2024-04-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2024q1_ix001 on player_game_nonparticipants_2024q1(create_dt);
+CREATE INDEX player_game_nonparticipants_2024q1_ix002 on player_game_nonparticipants_2024q1(game_id);
+CREATE INDEX player_game_nonparticipants_2024q1_ix003 on player_game_nonparticipants_2024q1(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2024q2 (
+ CHECK ( create_dt >= DATE '2024-04-01' AND create_dt < DATE '2024-07-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2024q2_ix001 on player_game_nonparticipants_2024q2(create_dt);
+CREATE INDEX player_game_nonparticipants_2024q2_ix002 on player_game_nonparticipants_2024q2(game_id);
+CREATE INDEX player_game_nonparticipants_2024q2_ix003 on player_game_nonparticipants_2024q2(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2024q3 (
+ CHECK ( create_dt >= DATE '2024-07-01' AND create_dt < DATE '2024-10-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2024q3_ix001 on player_game_nonparticipants_2024q3(create_dt);
+CREATE INDEX player_game_nonparticipants_2024q3_ix002 on player_game_nonparticipants_2024q3(game_id);
+CREATE INDEX player_game_nonparticipants_2024q3_ix003 on player_game_nonparticipants_2024q3(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2024q4 (
+ CHECK ( create_dt >= DATE '2024-10-01' AND create_dt < DATE '2025-01-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2024q4_ix001 on player_game_nonparticipants_2024q4(create_dt);
+CREATE INDEX player_game_nonparticipants_2024q4_ix002 on player_game_nonparticipants_2024q4(game_id);
+CREATE INDEX player_game_nonparticipants_2024q4_ix003 on player_game_nonparticipants_2024q4(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2025q1 (
+ CHECK ( create_dt >= DATE '2025-01-01' AND create_dt < DATE '2025-04-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2025q1_ix001 on player_game_nonparticipants_2025q1(create_dt);
+CREATE INDEX player_game_nonparticipants_2025q1_ix002 on player_game_nonparticipants_2025q1(game_id);
+CREATE INDEX player_game_nonparticipants_2025q1_ix003 on player_game_nonparticipants_2025q1(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2025q2 (
+ CHECK ( create_dt >= DATE '2025-04-01' AND create_dt < DATE '2025-07-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2025q2_ix001 on player_game_nonparticipants_2025q2(create_dt);
+CREATE INDEX player_game_nonparticipants_2025q2_ix002 on player_game_nonparticipants_2025q2(game_id);
+CREATE INDEX player_game_nonparticipants_2025q2_ix003 on player_game_nonparticipants_2025q2(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2025q3 (
+ CHECK ( create_dt >= DATE '2025-07-01' AND create_dt < DATE '2025-10-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2025q3_ix001 on player_game_nonparticipants_2025q3(create_dt);
+CREATE INDEX player_game_nonparticipants_2025q3_ix002 on player_game_nonparticipants_2025q3(game_id);
+CREATE INDEX player_game_nonparticipants_2025q3_ix003 on player_game_nonparticipants_2025q3(player_id);
+
+CREATE TABLE IF NOT EXISTS xonstat.player_game_nonparticipants_2025q4 (
+ CHECK ( create_dt >= DATE '2025-10-01' AND create_dt < DATE '2026-01-01' )
+) INHERITS (player_game_nonparticipants);
+
+CREATE INDEX player_game_nonparticipants_2025q4_ix001 on player_game_nonparticipants_2025q4(create_dt);
+CREATE INDEX player_game_nonparticipants_2025q4_ix002 on player_game_nonparticipants_2025q4(game_id);
+CREATE INDEX player_game_nonparticipants_2025q4_ix003 on player_game_nonparticipants_2025q4(player_id);
+
--- /dev/null
+CREATE OR REPLACE FUNCTION player_game_nonparticipants_ins()
+RETURNS TRIGGER AS $$
+BEGIN
+ IF (NEW.create_dt >= DATE '2020-01-01' AND NEW.create_dt < DATE '2020-04-01') THEN
+ INSERT INTO player_game_nonparticipants_2020Q1 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2020-04-01' AND NEW.create_dt < DATE '2020-07-01') THEN
+ INSERT INTO player_game_nonparticipants_2020Q2 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2020-07-01' AND NEW.create_dt < DATE '2020-10-01') THEN
+ INSERT INTO player_game_nonparticipants_2020Q3 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2020-10-01' AND NEW.create_dt < DATE '2021-01-01') THEN
+ INSERT INTO player_game_nonparticipants_2020Q4 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2021-01-01' AND NEW.create_dt < DATE '2021-04-01') THEN
+ INSERT INTO player_game_nonparticipants_2021Q1 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2021-04-01' AND NEW.create_dt < DATE '2021-07-01') THEN
+ INSERT INTO player_game_nonparticipants_2021Q2 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2021-07-01' AND NEW.create_dt < DATE '2021-10-01') THEN
+ INSERT INTO player_game_nonparticipants_2021Q3 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2021-10-01' AND NEW.create_dt < DATE '2022-01-01') THEN
+ INSERT INTO player_game_nonparticipants_2021Q4 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2022-01-01' AND NEW.create_dt < DATE '2022-04-01') THEN
+ INSERT INTO player_game_nonparticipants_2022Q1 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2022-04-01' AND NEW.create_dt < DATE '2022-07-01') THEN
+ INSERT INTO player_game_nonparticipants_2022Q2 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2022-07-01' AND NEW.create_dt < DATE '2022-10-01') THEN
+ INSERT INTO player_game_nonparticipants_2022Q3 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2022-10-01' AND NEW.create_dt < DATE '2023-01-01') THEN
+ INSERT INTO player_game_nonparticipants_2022Q4 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2023-01-01' AND NEW.create_dt < DATE '2023-04-01') THEN
+ INSERT INTO player_game_nonparticipants_2023Q1 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2023-04-01' AND NEW.create_dt < DATE '2023-07-01') THEN
+ INSERT INTO player_game_nonparticipants_2023Q2 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2023-07-01' AND NEW.create_dt < DATE '2023-10-01') THEN
+ INSERT INTO player_game_nonparticipants_2023Q3 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2023-10-01' AND NEW.create_dt < DATE '2024-01-01') THEN
+ INSERT INTO player_game_nonparticipants_2023Q4 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2024-01-01' AND NEW.create_dt < DATE '2024-04-01') THEN
+ INSERT INTO player_game_nonparticipants_2024Q1 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2024-04-01' AND NEW.create_dt < DATE '2024-07-01') THEN
+ INSERT INTO player_game_nonparticipants_2024Q2 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2024-07-01' AND NEW.create_dt < DATE '2024-10-01') THEN
+ INSERT INTO player_game_nonparticipants_2024Q3 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2024-10-01' AND NEW.create_dt < DATE '2025-01-01') THEN
+ INSERT INTO player_game_nonparticipants_2024Q4 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2025-01-01' AND NEW.create_dt < DATE '2025-04-01') THEN
+ INSERT INTO player_game_nonparticipants_2025Q1 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2025-04-01' AND NEW.create_dt < DATE '2025-07-01') THEN
+ INSERT INTO player_game_nonparticipants_2025Q2 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2025-07-01' AND NEW.create_dt < DATE '2025-10-01') THEN
+ INSERT INTO player_game_nonparticipants_2025Q3 VALUES (NEW.*);
+ ELSIF (NEW.create_dt >= DATE '2025-10-01' AND NEW.create_dt < DATE '2026-01-01') THEN
+ INSERT INTO player_game_nonparticipants_2025Q4 VALUES (NEW.*);
+ ELSE
+ RAISE EXCEPTION 'Date out of range. Fix the player_game_nonparticipants_ins() trigger!';
+ END IF;
+ RETURN NULL;
+END
+$$
+LANGUAGE plpgsql;
+
+DROP TRIGGER IF EXISTS player_game_nonparticipants_ins_trg ON xonstat.player_game_nonparticipants;
+CREATE TRIGGER player_game_nonparticipants_ins_trg
+BEFORE INSERT on xonstat.player_game_nonparticipants
+FOR EACH ROW EXECUTE PROCEDURE player_game_nonparticipants_ins();