Fix duplicate get probe by id api calls in traceroute visualizer #941
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
In this PR, I have fixed an includes check over allProbes array ref.
The probeData.prb_id is a number and the code stores it in allProbes array as a string.
So, while checking if the probe_id exists in allProbes array, we need to convert it to string first while comparing.
TracerouteMonitor component was storing duplicate probe ids in this ref: allProbes.
Expected behavior is to skip adding the probe id in the allProbes array.
Problem it solves is:
In this if block, there is an API call to RIPE Atlas to fetch the probe by ID. Since the bug allowed duplicate probe ids, the API requests were also made for duplicate probe ids. Which are redundant calls.
Related issue
How Has This Been Tested?
I observed this traceroute: 75404443.
Total 19 probes reached the target. Since, it should fetch only 19 probes data. So, it should only call 19 times to the https://atlas.ripe.net/api/v2/probes/ endpoint.
Tools used for testing:
Chrome devtool's network tab and console.
Testing strategy
Before fix: 49 requests for 19 probes (duplicate requests)
After fix: 19 requests for 19 probes. (1 request for 1 probe)
Affected areas
This ref is used as a prop in TracerouteProbesTable.
In this component, there's a computed ref called paginatedProbes, in which there's a set variable called uniqueProbes. It makes sure that a probe is not duplicated by adding from allProbes array into uniqueProbes set.
Since, I have removed the duplicates from the source itself, this Set is not required.
TracerouteProbesTable is only used by TracerouteMonitor component.
Screenshots (if appropriate):
Types of changes
Checklist: