From 84f8f43055f3afe9a567e464cbdb1ff6a39005f8 Mon Sep 17 00:00:00 2001 From: akrherz Date: Thu, 18 Jan 2024 10:12:45 -0600 Subject: [PATCH 1/2] fix: support huc12 scenario values --- htdocs/auto/mapper.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/auto/mapper.py b/htdocs/auto/mapper.py index 7700d69..d664964 100644 --- a/htdocs/auto/mapper.py +++ b/htdocs/auto/mapper.py @@ -165,6 +165,11 @@ def make_map(huc, ts, ts2, scenario, v, form): title = ( f"averaged between {ts:%-d %b} and {ts2:%-d %b} (2008-2023)" ) + # Compute what the huc12 scenario is for this scenario + cursor.execute( + "select huc12_scenario from scenarios where id = %s", (scenario,) + ) + huc12_scenario = cursor.fetchone()[0] # Check that we have data for this date! cursor.execute( @@ -187,6 +192,7 @@ def make_map(huc, ts, ts2, scenario, v, form): return ram.read(), False params = { "scenario": scenario, + "huc12_scenario": huc12_scenario, "sday1": f"{ts:%m%d}", "sday2": f"{ts2:%m%d}", "ts": ts, @@ -212,7 +218,7 @@ def make_map(huc, ts, ts2, scenario, v, form): f""" SELECT simple_geom as geom, dominant_tillage as data - from huc12 i WHERE scenario = :scenario {huclimiter} + from huc12 i WHERE scenario = :huc12_scenario {huclimiter} """ ), conn, @@ -234,7 +240,8 @@ def make_map(huc, ts, ts2, scenario, v, form): SELECT simple_geom as geom, coalesce(d.d, 0) * :dbcol as data from huc12 i LEFT JOIN data d - ON (i.huc_12 = d.huc_12) WHERE i.scenario = :scenario {huclimiter} + ON (i.huc_12 = d.huc_12) WHERE i.scenario = :huc12_scenario + {huclimiter} """ ), conn, @@ -255,7 +262,8 @@ def make_map(huc, ts, ts2, scenario, v, form): SELECT simple_geom as geom, coalesce(d.d, 0) * :dbcol as data from huc12 i LEFT JOIN data d - ON (i.huc_12 = d.huc_12) WHERE i.scenario = :scenario {huclimiter} + ON (i.huc_12 = d.huc_12) WHERE i.scenario = :huc12_scenario + {huclimiter} """ ), conn, @@ -361,6 +369,7 @@ def make_map(huc, ts, ts2, scenario, v, form): plt.savefig(ram, format="png", dpi=100) plt.close() ram.seek(0) + pgconn.close() return ram.read(), True From 4d4716726c4af19b1181da3edfba41fd081ae687 Mon Sep 17 00:00:00 2001 From: akrherz Date: Thu, 18 Jan 2024 10:13:31 -0600 Subject: [PATCH 2/2] ci: fixup scripts whilst here --- .github/workflows/build.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6fb235b..c60dac0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,7 +18,10 @@ jobs: - name: Setup CI from ci-tooling run: | + set -e git clone --depth 1 https://github.com/akrherz/iem-database.git database git clone --depth 1 https://github.com/akrherz/ci_tooling.git .ci_tooling - . .ci_tooling/postgres.sh - . .ci_tooling/iemwebfarm.sh + cd .ci_tooling + . postgres.sh + . iemwebfarm.sh + cd ..