Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add number disambiguation endpoint #805

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Andrew-Dickinson
Copy link
Member

@Andrew-Dickinson Andrew-Dickinson commented Jan 7, 2025

Adds a new API endpoint which aids in network/install number disambiguation. Given an ambiguous number, checks if it matches the NN for an existing node, and returns that node. If not, checks the given number as an install number and returns the attached node (if it exists).

Also returns fields to "show its work", which let you see what objects it found matching the requested number

Closes #801

Copy link

codecov bot commented Jan 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.93%. Comparing base (8feaa16) to head (a139832).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #805      +/-   ##
==========================================
+ Coverage   94.88%   94.93%   +0.05%     
==========================================
  Files          89       91       +2     
  Lines        3809     3852      +43     
==========================================
+ Hits         3614     3657      +43     
  Misses        195      195              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Andrew-Dickinson Andrew-Dickinson marked this pull request as ready for review January 8, 2025 02:01
Copy link
Collaborator

@WillNilges WillNilges left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple initial comments on this. Logic of the actual endpoint looks sound.


# TODO: Fix docs, maybe with custom install serializer?
class DisambiguateInstallOrNetworkNumber(APIView):
permission_classes = [HasDisambiguateNumberPermission]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about just letting anyone with read-only role or better use this instead of making a permission? Is there a service that needs least privilege?

if install_object and install_object.status == Install.InstallStatus.NN_REASSIGNED
else None
),
"exact_match_nonrecycled_install": (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, I think it would be clearer to have exact_match_install:

Suggested change
"exact_match_nonrecycled_install": (
"exact_match_install": (

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose an API for identifying ambiguous numbers
2 participants