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

Resource Fuzzing #374

Closed
wants to merge 3 commits into from
Closed

Resource Fuzzing #374

wants to merge 3 commits into from

Conversation

Polarpi
Copy link
Contributor

@Polarpi Polarpi commented May 28, 2020

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

  • Tests

Currently doesn't break any existing tests, but need to add new ones.

Screenshots

Screen Shot 2020-05-27 at 11 11 49 PM

@vercel
Copy link

vercel bot commented May 28, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/hack4impact/life-after-hate/7y2cphzzd
✅ Preview: https://life-after-hate-git-ec-resource-fuzzing.hack4impact1.now.sh

Update resource functions in utils/api to recompute spiderCoords after edit, add, delete resources
@codecov
Copy link

codecov bot commented May 28, 2020

Codecov Report

Merging #374 into master will increase coverage by 0.11%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            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              
Impacted Files Coverage Δ
frontend/src/pages/MapView/Map/index.jsx 86.95% <100.00%> (+1.24%) ⬆️
frontend/src/utils/api.js 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9734d00...50306b6. Read the comment docs.

@cypress
Copy link

cypress bot commented May 28, 2020



Test summary

42 0 0 0


Run details

Project Life After Hate
Status Passed
Commit 50306b6
Started May 28, 2020 5:12 AM
Ended May 28, 2020 5:16 AM
Duration 04:51 💡
OS Linux Ubuntu Linux - 16.04
Browser Electron 80

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) {
Copy link
Contributor

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 mapping 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.

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

Successfully merging this pull request may close these issues.

Resource Fuzzing
2 participants