-
Notifications
You must be signed in to change notification settings - Fork 0
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
Resource Fuzzing #374
Resource Fuzzing #374
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/hack4impact/life-after-hate/7y2cphzzd |
Update resource functions in utils/api to recompute spiderCoords after edit, add, delete resources
Codecov Report
@@ Coverage Diff @@
## master #374 +/- ##
==========================================
+ Coverage 97.17% 97.28% +0.11%
==========================================
Files 68 68
Lines 814 848 +34
Branches 59 60 +1
==========================================
+ Hits 791 825 +34
Misses 14 14
Partials 9 9
Continue to review full report at Codecov.
|
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
@@ -97,6 +97,41 @@ async function deleteResource(id) { | |||
).result; | |||
} | |||
|
|||
function spiderResources(resourceList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking great, @Polarpi. I'm wondering if we can refactor these two below methods a bit to get it in bit of a more functional programming style, which can make this complex logic a bit easier to debug if things aren't working as we expect. Right now we're doing the spidering computations to the array in-place, which results in there being side effects produced in the computation—for example, the resourceList
passed in as an argument to spiderResources
will now be modified after calling the function rather than returning a new, modified list, since JS is passing the reference to the array in for resourceList
and we're modifying that reference.
It would be great if we can refactor a bit of the logic here to have us map
over the resourceList
, and for each resource, calling computeSpideredCoordinates
which takes in resource
, the (unmodified) resourceList
, and returns a copy of resource
with the spiderCoordinates
added. Here's an example of how that's handled in the backend with distances. We don't need RamdaJS necessarily here, but if we can make the computeSpideredCoordinates
be solely responsible for managing adding the coordinates to one resource object and returning a copy with those values added, then it becomes a matter of us map
ping through resourceList
to do this for each resource object.
I definitely see the challenge in having computeSpideredCoordinates
do it this way rather than filtering and modifying them all simultaneously. Definitely open to alternate solutions here, this is just a suggestion—I think the main priority is to make sure that we're not causing unintended side effects by calling spiderResources
to the passed in array or underlying objects, which is why immutability is key here.
Status: 🚧
Description
If multiple resources have the same address, the markers on the map are displayed on top of each other, making them indistinguishable. This solution fuzzes the resources by adding a spiderCoordinate, which is a recomputed [lat, long] with the resources redistributed along the path of a circle. The map then shows the marker at this spiderCoordinate.
Fixes #347
Todos
Currently doesn't break any existing tests, but need to add new ones.
Screenshots