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

187849414 Autodetect Boundary Type #1613

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

Conversation

tealefristoe
Copy link
Contributor

@tealefristoe tealefristoe commented Nov 12, 2024

PT Stories:
https://www.pivotaltracker.com/story/show/187849414
https://www.pivotaltracker.com/story/show/188491735
https://www.pivotaltracker.com/story/show/188491712

This PR implements related behavior requested in three different stories.

  • Boundary attributes are now automatically detected.
    • Just like in v2, attributes with one of several special names will be treated as a boundary attribute.
    • Unlike in v2, an attribute will be considered of type boundary if its values all "look" like boundaries.
      • Bill started this one. I cleaned up the functions that he wrote a bit, but I suspect the way boundary data is recognized could be improved. Without having that many examples to work with or rules to follow, though, I just kept what he had.
  • Boundary values are rendered as thumbnail images in the table.
  • The lookupBoundary function has been implemented.
    • This can most easily be seen in the Roller Coasters example document.
    • Currently, we don't have a general solution for how to host boundary documents. Until we have that figured out, I added the state boundary document to the Codap. This means two things:
      • The document is included whenever Codap is loaded, not just when it is needed.
      • Only the state data is currently available, not any other boundary data.

Other changes:

  • basicCanonicalNameToDependency was moved from formula-dependency-utils.ts to name-mapping-utils.ts to avoid an import cycle. This was a very straightforward change to make. I'm not sure if there was some organizational reason for this function to be in one file rather than the other.

@tealefristoe tealefristoe marked this pull request as draft November 12, 2024 22:31
Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 97.93814% with 2 lines in your changes missing coverage. Please review.

Project coverage is 85.63%. Comparing base (6f3b40e) to head (92adb98).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
...3/src/models/formula/functions/lookup-functions.ts 97.29% 1 Missing ⚠️
v3/src/models/formula/utils/name-mapping-utils.ts 90.90% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1613       +/-   ##
===========================================
+ Coverage   67.88%   85.63%   +17.75%     
===========================================
  Files         600      602        +2     
  Lines       30405    30495       +90     
  Branches     8351     7809      -542     
===========================================
+ Hits        20639    26113     +5474     
+ Misses       9611     4227     -5384     
  Partials      155      155               
Flag Coverage Δ
cypress 75.14% <91.76%> (+31.15%) ⬆️
jest 52.70% <91.75%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

cypress bot commented Nov 12, 2024

codap-v3    Run #5248

Run Properties:  status check passed Passed #5248  •  git commit 92adb98571: Merge main.
Project codap-v3
Branch Review 187849414-autodetect-boundary-type-v3
Run status status check passed Passed #5248
Run duration 06m 05s
Commit git commit 92adb98571: Merge main.
Committer Teale Fristoe
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 35
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 221
View all changes introduced in this branch ↗︎

@tealefristoe tealefristoe marked this pull request as ready for review November 15, 2024 13:28
Copy link
Member

@kswenson kswenson left a comment

Choose a reason for hiding this comment

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

👍 Looks good -- suggestions are mainly to rearrange some of the dependencies.

expect(() => evaluate(`lookupBoundary("US_state_boundaries", "Alaska")`)).toThrow()
expect(() => evaluate(`lookupBoundary(Mammal, "Alaska")`)).toThrow()

// Second argument can't be a non-existant symbol
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Second argument can't be a non-existant symbol
// Second argument can't be a non-existent symbol

Copy link
Member

Choose a reason for hiding this comment

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

I'm not quite sure what to do with this file, but maybe combine it with boundary-utils.ts (nee geojson-utils.ts) for now? Leave the src/boundaries folder for the GeoJSON files for the nonce, but it will go away once the boundary files are being loaded remotely, at which point maybe the rest of the relationships will become more clear as well.

@@ -26,10 +26,12 @@
*/

import { Instance, SnapshotIn, types } from "mobx-state-tree"
import { kPolygonNames } from "../../components/map/map-types"
Copy link
Member

Choose a reason for hiding this comment

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

Attribute shouldn't be importing from the map component. I'd suggest moving kPolygonNames to utilities/boundary-utils.ts (nee geojson-utils.ts).

Copy link
Member

Choose a reason for hiding this comment

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

Rename to boundary-utils.test.ts.

Copy link
Member

Choose a reason for hiding this comment

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

Rename to boundary-utils.ts.

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.

3 participants