forked from smnorris/bcfishpass
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added permission assignment to auto_rank.py * Update auto_rank.py with truncate instead of drop * Created auto_rank.sql This file includes a function to create the ranked_barrier table for a given wcrp in the given schema * merge, fix typo --------- Co-authored-by: Simon Norris <[email protected]>
- Loading branch information
1 parent
f304abd
commit 03d8a41
Showing
3 changed files
with
108 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
#!/bin/bash | ||
set -euxo pipefail | ||
|
||
|
||
# update crossings_vw | ||
psql $DATABASE_URL -f sql/modelled_crossing_office_review_date.sql | ||
psql $DATABASE_URL -c "update bcfishpass.db_version set tag = '${PWD##*/}'" | ||
|
||
# FWCP | ||
echo "On systems supporting FPTWG reporting, restore views by running:" | ||
echo "psql $DATABASE_URL -f ../v0.5.0/sql/views/fptwg_freshwater_fish_habitat_accessibility_model.sql" | ||
echo "psql $DATABASE_URL -f ../v0.5.0/sql/reports/fptwg_assmt_wsd_summary_vw.sql" | ||
|
||
# CWF | ||
echo "On systems supporting CWF WCRP reporting, add auto_rank.sql" | ||
echo "psql $DATABASE_URL -f sql/auto_rank.sql" | ||
|
||
# note version | ||
psql $DATABASE_URL -c "update bcfishpass.db_version set tag = '${PWD##*/}'" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- create table for ranked list | ||
|
||
CREATE FUNCTION bcfishpass.create_rank_table(schema_name text, wcrp text) | ||
RETURNS VOID | ||
LANGUAGE plpgsql AS | ||
$func$ | ||
BEGIN | ||
|
||
EXECUTE format(' | ||
CREATE TABLE IF NOT EXISTS %I.%I | ||
( | ||
aggregated_crossings_id text, | ||
crossing_source text, | ||
crossing_feature_type text, | ||
pscis_status text, | ||
crossing_type_code text, | ||
barrier_status text, | ||
pscis_road_name text, | ||
pscis_assessment_comment text, | ||
pscis_assessment_date date, | ||
utm_zone integer, | ||
utm_easting integer, | ||
utm_northing integer, | ||
blue_line_key integer, | ||
watershed_group_code integer, | ||
gnis_stream_name text, | ||
barriers_anthropogenic_dnstr text, | ||
barriers_anthropogenic_habitat_wcrp_upstr text, | ||
barriers_anthropogenic_habitat_wcrp_upstr_count integer, | ||
all_spawning_km double precision, | ||
all_spawning_belowupstrbarriers_km double precision, | ||
all_rearing_km double precision, | ||
all_rearing_belowupstrbarriers_km double precision, | ||
all_spawningrearing_km double precision, | ||
all_spawningrearing_belowupstrbarriers_km double precision, | ||
set_id numeric, | ||
total_hab_gain_set numeric, | ||
num_barriers_set integer, | ||
avg_gain_per_barrier numeric, | ||
dnstr_set_ids character varying[], | ||
rank_avg_gain_per_barrier numeric, | ||
rank_avg_gain_tiered numeric, | ||
tier_combined character varying, | ||
geom geometry | ||
)', | ||
schema_name, | ||
'ranked_barriers_' || wcrp | ||
); | ||
|
||
END | ||
$func$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters