From efc4c1371d2fe0745fc29c46be9e523dc92f210f Mon Sep 17 00:00:00 2001 From: akrherz Date: Thu, 26 Oct 2023 09:13:21 -0500 Subject: [PATCH 1/3] fix: address issues per log review --- htdocs/iemre/multiday.py | 7 +++++-- htdocs/plotting/auto/scripts/p99.py | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/htdocs/iemre/multiday.py b/htdocs/iemre/multiday.py index f2d7230805..87394fe323 100644 --- a/htdocs/iemre/multiday.py +++ b/htdocs/iemre/multiday.py @@ -34,8 +34,11 @@ def application(environ, start_response): """Go Main Go""" if "date1" not in environ: raise IncompleteWebRequest("GET date1= parameter missing") - ts1 = datetime.datetime.strptime(environ.get("date1"), "%Y-%m-%d") - ts2 = datetime.datetime.strptime(environ.get("date2"), "%Y-%m-%d") + try: + ts1 = datetime.datetime.strptime(environ.get("date1"), "%Y-%m-%d") + ts2 = datetime.datetime.strptime(environ.get("date2"), "%Y-%m-%d") + except ValueError: + raise IncompleteWebRequest("Invalid date(s) provided") if ts1 > ts2: (ts1, ts2) = (ts2, ts1) if ts1.year != ts2.year: diff --git a/htdocs/plotting/auto/scripts/p99.py b/htdocs/plotting/auto/scripts/p99.py index 0c29e0a0f6..46f4e6aba9 100644 --- a/htdocs/plotting/auto/scripts/p99.py +++ b/htdocs/plotting/auto/scripts/p99.py @@ -54,9 +54,9 @@ def plotter(fdict): df = pd.read_sql( """ WITH days as ( - select generate_series('%s-01-01'::date, '%s-12-31'::date, + select generate_series(%s, %s, '1 day'::interval)::date as day, - to_char(generate_series('%s-01-01'::date, '%s-12-31'::date, + to_char(generate_series(%s, %s, '1 day'::interval)::date, 'mmdd') as sday ), climo as ( @@ -78,7 +78,15 @@ def plotter(fdict): (t.sday = c.sday) ORDER by t.day ASC """, conn, - params=(year, year, year, year, station, station, year), + params=( + datetime.date(year, 1, 1), + datetime.date(year, 12, 31), + datetime.date(year, 1, 1), + datetime.date(year, 12, 31), + station, + station, + year, + ), index_col="day", ) if df.empty or df["stddev_high"].min() == 0: From 395ef6c122c2900c2eab338d3c5bc1504c06de34 Mon Sep 17 00:00:00 2001 From: akrherz Date: Thu, 26 Oct 2023 09:14:58 -0500 Subject: [PATCH 2/3] chore: set ruff line length to match black --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index ac809013c2..37240a9259 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,5 +2,6 @@ line-length = 79 [tool.ruff] +line-length = 79 select = ["E", "F", "I"] target-version = "py39" From 3de8ec897fd225d48fbde1c9687eb8c7688db817 Mon Sep 17 00:00:00 2001 From: akrherz Date: Thu, 26 Oct 2023 09:24:13 -0500 Subject: [PATCH 3/3] mnt: address line-length lint --- cgi-bin/request/coop.py | 4 +- htdocs/plotting/auto/index.py | 3 +- htdocs/plotting/auto/scripts/p59.py | 4 +- htdocs/plotting/auto/scripts100/p147.py | 9 +++-- htdocs/plotting/auto/scripts100/p170.py | 50 +++++++++++------------- htdocs/projects/iembot/mastodon/index.py | 4 +- 6 files changed, 37 insertions(+), 37 deletions(-) diff --git a/cgi-bin/request/coop.py b/cgi-bin/request/coop.py index 5e2f976234..3f4980c812 100644 --- a/cgi-bin/request/coop.py +++ b/cgi-bin/request/coop.py @@ -697,8 +697,8 @@ def do_swat(ctx): f""" WITH scenario as ( SELECT - ('{thisyear}-'||month||'-'||extract(day from day))::date as day, - high, low, precip, station from {table} + ('{thisyear}-'||month||'-'||extract(day from day))::date + as day, high, low, precip, station from {table} WHERE station = ANY(:sids) and day >= :asts and year = :scenario_year), obs as ( diff --git a/htdocs/plotting/auto/index.py b/htdocs/plotting/auto/index.py index 1eb8228927..a17c0a3604 100644 --- a/htdocs/plotting/auto/index.py +++ b/htdocs/plotting/auto/index.py @@ -138,7 +138,8 @@ def map_select_widget(network, name): return f"""   -