44 lines
3.5 KiB
SQL
44 lines
3.5 KiB
SQL
-- Sample catalogs and dashboard configuration. Player histories are generated by realistic_seed.py.
|
|
SET search_path TO analytics, public;
|
|
INSERT INTO games(name,roblox_experience_id,sample_key,properties) VALUES
|
|
('Willow''s Park',18472930652,'willow-v1',jsonb_build_object('sampleAsOf',now(),'description','Social exploration and collection')),
|
|
('Orbit Racers',9482036192,'orbit-v1',jsonb_build_object('sampleAsOf',now(),'description','Competitive racing')),
|
|
('Dungeon Workshop',NULL,'dungeon-v1',jsonb_build_object('sampleAsOf',now(),'description','Adventure and crafting'))
|
|
ON CONFLICT(sample_key) DO NOTHING;
|
|
|
|
|
|
INSERT INTO activity_definitions(game_id,key,name,start_event,end_event,configuration)
|
|
SELECT g.id,d.key,d.name,d.start_event,d.end_event,d.config::jsonb FROM games g CROSS JOIN (VALUES
|
|
('shop','Shop visit','shop_opened','shop_closed','{"steps":["product_viewed","buy_prompt_shown","purchase_completed"],"fields":["product_id","purchase_amount","currency_balance"]}'),
|
|
('minigame','Minigame run','minigame_started','minigame_ended','{"steps":["round_started","checkpoint_reached","round_ended"],"fields":["score","rounds"]}'),
|
|
('quest','Quest attempt','quest_started','quest_ended','{"steps":["objective_started","objective_completed"],"fields":["quest_id","reward"]}')
|
|
) d(key,name,start_event,end_event,config) WHERE g.sample_key IN ('willow-v1','orbit-v1','dungeon-v1');
|
|
|
|
INSERT INTO player_fields(game_id,key,label,format,source)
|
|
SELECT g.id,f.* FROM games g CROSS JOIN (VALUES
|
|
('level','Level','number','snapshot'),('cash','Cash balance','currency','snapshot'),
|
|
('cashEarned','Cash earned','currency','snapshot'),('cashSpent','Cash spent','currency','snapshot'),
|
|
('robux','Robux spent','robux','snapshot'),('purchases','Purchases','number','snapshot'),
|
|
('playtime','Lifetime playtime','duration','derived'),('sessions','Sessions','number','derived'),
|
|
('avgSession','Average session','duration','derived'),('activeDays','Active days (30d)','number','derived'),
|
|
('levelsGained','Levels gained','number','snapshot'),('quests','Quests completed','number','snapshot'),
|
|
('achievements','Achievements','number','snapshot'),('lastSeen','Minutes since last seen','number','derived'),
|
|
('robuxPerHour','Robux per playtime hour','decimal','derived')
|
|
) f WHERE g.sample_key IN ('willow-v1','orbit-v1','dungeon-v1');
|
|
INSERT INTO player_fields SELECT id,'roundWins','Rounds won','number','snapshot' FROM games WHERE sample_key='orbit-v1';
|
|
INSERT INTO column_templates(game_id,key,label,columns)
|
|
SELECT g.id,t.key,t.label,t.columns::jsonb FROM games g CROSS JOIN (VALUES
|
|
('overview','Overview','["level","cash","playtime","sessions","lastSeen"]'),
|
|
('economy','Economy','["cash","cashEarned","cashSpent","robux","purchases","robuxPerHour"]'),
|
|
('progress','Progress','["level","levelsGained","quests","achievements","playtime"]'),
|
|
('engagement','Engagement','["playtime","sessions","avgSession","activeDays","lastSeen"]')
|
|
) t(key,label,columns) WHERE g.sample_key IN ('willow-v1','orbit-v1','dungeon-v1');
|
|
|
|
INSERT INTO products(game_id,roblox_product_id,name,current_price_robux)
|
|
SELECT g.id,8000000+g.id*100+n,names[n],prices[n]
|
|
FROM games g CROSS JOIN generate_series(1,4) n
|
|
CROSS JOIN (SELECT ARRAY['Double XP','Gem bundle','Starter pack','Coin bundle'] names,ARRAY[49,149,399,999] prices) catalog
|
|
WHERE g.sample_key IN ('willow-v1','orbit-v1','dungeon-v1');
|
|
|
|
UPDATE player_fields SET source='derived' WHERE key IN ('robux','purchases') AND game_id IN (SELECT id FROM games WHERE sample_key IN ('willow-v1','orbit-v1','dungeon-v1'));
|