mirror of
https://github.com/norohind/jubilant-system.git
synced 2025-06-11 12:12:05 +03:00
Add squads_view_2 (current season score, prev season score)
This commit is contained in:
parent
f67aa8826a
commit
b904e6fe8f
5
doc.txt
5
doc.txt
@ -10,9 +10,12 @@ update/insert new data to DB
|
|||||||
alert if new data accord to triggers
|
alert if new data accord to triggers
|
||||||
|
|
||||||
DB tables
|
DB tables
|
||||||
1. squads_view - contains current state of squadrons, builds automatically by update/insert/delete triggers for `transactions`
|
1. squads_view - contains current state of squadrons
|
||||||
note: done as view, not a table
|
note: done as view, not a table
|
||||||
|
|
||||||
|
1a. squads_view_2 - as squads_view but with additional columns: current_season_score and previous_season_score
|
||||||
|
with sums for current season and previous season
|
||||||
|
|
||||||
2. squads_states - contains history of all updates for every squad, triggers in this table update `view` table
|
2. squads_states - contains history of all updates for every squad, triggers in this table update `view` table
|
||||||
squad_id int
|
squad_id int
|
||||||
name text (`name` field, name of the squadron)
|
name text (`name` field, name of the squadron)
|
||||||
|
@ -101,4 +101,57 @@ where inserted_timestamp in (
|
|||||||
group by squad_id)
|
group by squad_id)
|
||||||
group by squad_id;
|
group by squad_id;
|
||||||
|
|
||||||
create index idx_squads_states_0 on squads_states (squad_id);
|
create index idx_squads_states_0 on squads_states (squad_id);
|
||||||
|
|
||||||
|
create view if not exists squads_view_2
|
||||||
|
as
|
||||||
|
select squad_id,
|
||||||
|
name,
|
||||||
|
tag,
|
||||||
|
owner_name,
|
||||||
|
owner_id,
|
||||||
|
platform,
|
||||||
|
created,
|
||||||
|
created_ts,
|
||||||
|
accepting_new_members,
|
||||||
|
power_id,
|
||||||
|
power_name,
|
||||||
|
super_power_id,
|
||||||
|
super_power_name,
|
||||||
|
faction_id,
|
||||||
|
faction_name,
|
||||||
|
user_tags,
|
||||||
|
member_count,
|
||||||
|
pending_count,
|
||||||
|
full,
|
||||||
|
public_comms,
|
||||||
|
public_comms_override,
|
||||||
|
public_comms_available,
|
||||||
|
current_season_trade_score,
|
||||||
|
previous_season_trade_score,
|
||||||
|
current_season_combat_score,
|
||||||
|
previous_season_combat_score,
|
||||||
|
current_season_exploration_score,
|
||||||
|
previous_season_exploration_score,
|
||||||
|
current_season_cqc_score,
|
||||||
|
previous_season_cqc_score,
|
||||||
|
current_season_bgs_score,
|
||||||
|
previous_season_bgs_score,
|
||||||
|
current_season_powerplay_score,
|
||||||
|
previous_season_powerplay_score,
|
||||||
|
current_season_aegis_score,
|
||||||
|
previous_season_aegis_score,
|
||||||
|
current_season_trade_score +
|
||||||
|
current_season_combat_score +
|
||||||
|
current_season_exploration_score +
|
||||||
|
current_season_cqc_score +
|
||||||
|
current_season_bgs_score +
|
||||||
|
current_season_powerplay_score +
|
||||||
|
current_season_aegis_score as current_season_score,
|
||||||
|
previous_season_trade_score +
|
||||||
|
previous_season_combat_score +
|
||||||
|
previous_season_exploration_score +
|
||||||
|
previous_season_cqc_score +
|
||||||
|
previous_season_bgs_score +
|
||||||
|
previous_season_powerplay_score +
|
||||||
|
previous_season_aegis_score as previous_season_score, max(inserted_timestamp) as inserted_timestamp from squads_states group by squad_id having tag is not null;
|
Loading…
x
Reference in New Issue
Block a user