Skip to content
Snippets Groups Projects
Select Git revision
  • 9b49096aac37474ce3009ae02db01b09b9bd97b6
  • jk default protected
2 results

setup.cfg

Blame
  • upgrade-20210924.sql 607 B
    SET ROLE 'mo_osmo';
    
    CREATE VIEW region_descendants AS
    	WITH RECURSIVE descendant_regions(place_id, descendant) AS (
    		SELECT place_id, place_id FROM places WHERE level BETWEEN 1 AND 2
    		UNION SELECT r.place_id, p.place_id
    		      FROM descendant_regions r, places p
    		      WHERE p.parent = r.descendant
    	) SELECT place_id AS region, descendant FROM descendant_regions;
    
    CREATE VIEW region_stats AS
    	SELECT c.round_id, rd.region, p.state, count(*)
    	FROM participations p
    	JOIN contests c USING(contest_id)
    	JOIN region_descendants rd ON rd.descendant = c.place_id
    	GROUP BY c.round_id, rd.region, p.state;