Skip to content

Commit

Permalink
Implement handling of unavailable biology image loops
Browse files Browse the repository at this point in the history
Modified the biology image loop handling process to deal with cases where image
loops are not available. This is necessary due to the removal of the ciliates
variable, and the name change of the turbidity variable in V2021-11.

A new list, 'unavailable_loops' has been created to store image loops
that are not available. Those loops are then removed from a copy of the biology
loops data structure to produce the image loops data structure that is passed to
the page renderer.
  • Loading branch information
douglatornell committed Feb 7, 2024
1 parent 06200d0 commit 649163b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions salishsea_site/views/salishseacast.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

"""salishsea_site SalishSeaCast views
"""
import copy
import logging
import os
import urllib.parse
Expand Down Expand Up @@ -742,11 +743,14 @@ def nowcast_biology(request):
],
"biology loops": [],
}
unavailable_loops = []
for image_loop in biology_image_loops.loops:
images_available = image_loop.available("nowcast-green", results_date)
if images_available:
available_figures["biology loops"].append(images_available)
image_loop.hrs = image_loop.hours("nowcast-green", results_date)
if not images_available:
unavailable_loops.append(image_loop)
continue
available_figures["biology loops"].append(images_available)
image_loop.hrs = image_loop.hours("nowcast-green", results_date)
if not any(available_figures["baynes sound"] + available_figures["biology loops"]):
raise HTTPNotFound
figure_links = (
Expand All @@ -757,13 +761,16 @@ def nowcast_biology(request):
if available_figures["baynes sound"]
else []
)
image_loops = copy.deepcopy(biology_image_loops)
for image_loop in unavailable_loops:
image_loops.loops.remove(image_loop)
return {
"results_date": results_date,
"run_type": "nowcast-green",
"run_date": results_date,
"figure_links": figure_links,
"available_figures": available_figures,
"image_loops": biology_image_loops,
"image_loops": image_loops,
"baynes_sound_figures": baynes_sound_figures,
}

Expand Down

0 comments on commit 649163b

Please sign in to comment.