Skip to content

DBC22-6145: not showing all 30km away stations for cameras#1326

Open
bcgov-brwang wants to merge 6 commits into
mainfrom
bugfix/DBC22-6145-3
Open

DBC22-6145: not showing all 30km away stations for cameras#1326
bcgov-brwang wants to merge 6 commits into
mainfrom
bugfix/DBC22-6145-3

Conversation

@bcgov-brwang
Copy link
Copy Markdown
Collaborator

📝 Submitter

🔗 JIRA Ticket


✅ Quality Assurance & Requirements

  • Requirements Met: I have confirmed that all acceptance criteria from the JIRA ticket are fulfilled.
  • Tested desktop in local or dev envs
  • Tested mobile in local or dev envs
  • Ran unit tests locally
  • SonarCloud: I have verified that the SonarCloud analysis is clean/passing for this branch.

⚙️ Configuration & Environment

  • New Env Variables: Does this PR require new environment variables? (Yes/No)

    If yes, please list them here and ensure they are added to secret manager, the .env.example. and the Vault by an STA.

🧪 How to Test (if required)

  1. Deploy to dev.
  2. Verify regional and hef weather stations away from 30km not showing for cameras on details page

🔍 Reviewer Checklist

  • Reviewed code for logic and cleanliness
  • Re-tested desktop/mobile in local or dev envs
  • Verified no new console warnings/errors
  • Confirmed that any new env variables are understood/documented

@wmuldergov
Copy link
Copy Markdown
Collaborator

While testing I got this

1002880000@dev-drivebc-django-7f6cfd94d7-htcrm:/app/backend$ . /vault/secrets/secrets.env && python manage.py update_relations
Traceback (most recent call last):
  File "/app/backend/manage.py", line 22, in <module>
    main()
    ~~~~^^
  File "/app/backend/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
    utility.execute()
    ~~~~~~~~~~~~~~~^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/__init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 420, in run_from_argv
    self.execute(*args, **cmd_options)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/core/management/base.py", line 464, in execute
    output = self.handle(*args, **options)
  File "/app/backend/apps/shared/management/commands/update_relations.py", line 7, in handle
    update_object_relations()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/app/backend/apps/shared/tasks.py", line 67, in update_object_relations
    update_camera_relations()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/app/backend/apps/webcam/tasks.py", line 572, in update_camera_relations
    update_camera_weather_station(camera, RegionalWeather)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/app/backend/apps/webcam/tasks.py", line 550, in update_camera_weather_station
    stations_qs = stations_qs.filter(
        distance__lte=D(km=30),
        elevation__lte=camera.elevation + 300,
        elevation__gte=camera.elevation - 300,
    )
  File "/usr/local/lib/python3.13/site-packages/django/db/models/query.py", line 1495, in filter
    return self._filter_or_exclude(False, args, kwargs)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/query.py", line 1513, in _filter_or_exclude
    clone._filter_or_exclude_inplace(negate, args, kwargs)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/query.py", line 1523, in _filter_or_exclude_inplace
    self._query.add_q(Q(*args, **kwargs))
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1648, in add_q
    clause, _ = self._add_q(q_object, can_reuse)
                ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1680, in _add_q
    child_clause, needed_inner = self.build_filter(
                                 ~~~~~~~~~~~~~~~~~^
        child,
        ^^^^^^
    ...<7 lines>...
        update_join_types=update_join_types,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1528, in build_filter
    lookups, parts, reffed_expression = self.solve_lookup_type(arg, summarize)
                                        ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1335, in solve_lookup_type
    _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
                                ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.13/site-packages/django/db/models/sql/query.py", line 1813, in names_to_path
    raise FieldError(
    ...<2 lines>...
    )
django.core.exceptions.FieldError: Cannot resolve keyword 'elevation' into field. Choices are: code, conditions, created_at, distance, forecast_group, forecast_issued, hourly_forecast_group, id, location, location_latitude, location_longitude, modified_at, name, observed, region, station, sunrise, sunset, warnings, webcam
1002880000@dev-drivebc-django-7f6cfd94d7-htcrm:/app/backend$ 

DBC22-6145: fixed elevation not found error
@bcgov-brwang bcgov-brwang force-pushed the bugfix/DBC22-6145-3 branch from f3f74ac to 85123c9 Compare May 12, 2026 15:04
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@bcgov-brwang bcgov-brwang marked this pull request as ready for review May 12, 2026 15:16
@wmuldergov
Copy link
Copy Markdown
Collaborator

No more error when doing the update_relations.

Couple things I noticed:

  1. If a cam has no weather nearby it just does the loading animation (https://dev.drivebc.ca/cameras/970)
  2. If you go from one cam to another, and lets say cam A had a weather station linked to it, but cam B did not, then it will keep showing the weather from cam A. When you eventually pick a cam that does have weather linked to it, it will update.

@wmuldergov wmuldergov added the pending rework If the PR needs some re-work by the developer label May 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pending rework If the PR needs some re-work by the developer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants