Skip to content

Commit

Permalink
Only show node name labels on NN map dots (#315)
Browse files Browse the repository at this point in the history
* Only show node name labels on NN map dots

* Fix null-pointer and add test case for new logic
  • Loading branch information
Andrew-Dickinson authored Apr 2, 2024
1 parent 6ba07ca commit f9b5d1d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/meshapi/serializers/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ def get_building_coordinates(self, install: Install) -> List[float]:
return [building.longitude, building.latitude, building.altitude]

def get_node_name(self, install: Install) -> Optional[str]:
# Only include the node name if this is an old-school "node as install" situation
# to prevent showing the same name on multiple map dots. For the NN != install number
# case we add extra fake install objects with install_number = NN so that we can still
# see the node name
node = install.node
return node.name if node else None
return node.name if node and install.node.network_number == install.install_number else None

def get_synthetic_notes(self, install: Install) -> Optional[str]:
if not install.node:
Expand Down
2 changes: 2 additions & 0 deletions src/meshapi/tests/test_map_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def test_install_data(self):
nodes.append(
Node(
network_number=567,
name="Fancy Node",
status=Node.NodeStatus.PLANNED,
latitude=40.724868,
longitude=-73.987881,
Expand Down Expand Up @@ -314,6 +315,7 @@ def test_install_data(self):
},
{
"id": 567,
"name": "Fancy Node",
"coordinates": [-73.9917741, 40.6962265, 66.0],
"requestDate": 1706331600000,
"roofAccess": True,
Expand Down
1 change: 1 addition & 0 deletions src/meshapi/views/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def get_queryset(self):
all_installs.append(
Install(
install_number=node.network_number,
node=node,
status=Install.InstallStatus.NN_REASSIGNED
if node.status == node.NodeStatus.ACTIVE
else Install.InstallStatus.REQUEST_RECEIVED,
Expand Down

0 comments on commit f9b5d1d

Please sign in to comment.