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

new Node.js demo for batch geocoding a .csv #105

Merged
merged 1 commit into from
Feb 22, 2018

Conversation

mpayson
Copy link
Contributor

@mpayson mpayson commented Jan 24, 2018

Hey team, first take on a batch geocode sample for Node, would love feedback on:

  • Is best batch geocode sample a Node script?
  • General logic/structure/style/formatting (my first PR!)
  • Excel thinks the output .csv is corrupt, not sure why or how to fix? might be local problem

@phpmaps @jgravois

@coveralls
Copy link

coveralls commented Jan 25, 2018

Coverage Status

Coverage remained the same at 100.0% when pulling 5b10616 on mpayson:mp-batch-geocode into 7d9a593 on Esri:master.

@jgravois
Copy link
Contributor

very, very cool @mpayson!

i've got other fires blazing now, but i'll find time to review and help you get this landed soon.

@Esri Esri deleted a comment from coveralls Jan 26, 2018
@Esri Esri deleted a comment from coveralls Jan 26, 2018
@jgravois jgravois self-assigned this Feb 1, 2018
Copy link
Contributor

@jgravois jgravois left a comment

Choose a reason for hiding this comment

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

this looks great! we can merge after you have a chance to address my feedback.

@@ -0,0 +1,7 @@
# Running this demo

1. `$ git clone https://github.com/mpayson/arcgis-rest-js.git`
Copy link
Contributor

@jgravois jgravois Feb 7, 2018

Choose a reason for hiding this comment

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

all the other demo instructions assume the repo has already been cloned.

nothing wrong with you deviating, but if you do, you should point folks at Esri/arcgis-rest-js 😄.


1. `$ git clone https://github.com/mpayson/arcgis-rest-js.git`
2. `$ cd arcgis-rest-js/demos/batch-geocoder/`
3. `$ npm install`
Copy link
Contributor

Choose a reason for hiding this comment

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

since this is a monorepo, we shouldn't direct them to npm install inside individual packages.

instead they should run npm run bootstrap in the root of the repo to appropriately symlink the needed dependencies.

resultMap = mapResults(res);
output = data.map((row, i) => {
id = row[config.fieldmap.OBJECTID] || i;
return {...row, ...resultMap[id]};
Copy link
Contributor

Choose a reason for hiding this comment

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

since you're using spread operators and other fancy new JS stuff, you need to make a point in the doc of explaining that Node.js 8.x or higher is required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

✅ added dependency to readme.

I think spread etc only requires >6.x? Can also update to support older versions?

un: "<USERNAME>",
pw: "<PASSWORD>",
csv: "<PATH/TO/CSV>",
fieldmap: "<CSV TO REQUEST FIELD MAP OR ADDRESS FIELD>"
Copy link
Contributor

Choose a reason for hiding this comment

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

i'd recommend:

  1. encasing un and your other properties as strings
  2. just hardcoding the .csv path to use your example file.
  3. either doing the same with the fieldmap or at least including it in copy/pasteable form in a code comment in the same file.
{ 
  "fieldmap": {
    "postal": "ZIPCODE"
  }
}

in general, the fieldmap was the biggest point of confusion when i ran your app. it'd make this sample substantially more self explanatory if you talked through what it is and what it is doing.

@@ -0,0 +1,36 @@
{
"name": "batch-geocoder",
"version": "0.0.1",
Copy link
Contributor

Choose a reason for hiding this comment

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

use the same version number as everything else in the repo. 1.0.2.

"arcgis-rest-js"
],
"author": "Max Payson (mpayson)",
"license": "ISC",
Copy link
Contributor

@jgravois jgravois Feb 7, 2018

Choose a reason for hiding this comment

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

"@esri/arcgis-rest-request": "^1.0.2",
"isomorphic-fetch": "^2.2.1",
"isomorphic-form-data": "^1.0.0",
"papaparse": "^4.3.6"
Copy link
Contributor

@jgravois jgravois Feb 7, 2018

Choose a reason for hiding this comment

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

you should include "private": true to ensure this doesn't accidentally get published to npm.

https://docs.npmjs.com/files/package.json#license

Copy link
Contributor Author

Choose a reason for hiding this comment

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

here

{
"name": "batch-geocoder",
"version": "0.0.1",
"description": "arcgis-res-js batch geocode sample",
Copy link
Contributor

Choose a reason for hiding this comment

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

arcgis-res-js > arcgis-rest-js (with a 't')

@jgravois
Copy link
Contributor

jgravois commented Feb 9, 2018

at some point, it'd be worth considering using something like Sanitize.js or even a simple regex to remove <script> tags from within values inside the .csv (in the unlikely event of an XSS).

@jgravois
Copy link
Contributor

are you going to have a chance in the next two weeks to take one more pass at this? i'd like to show it off at DevSummit so i can get it landed if push comes to shove.

@jgravois jgravois changed the title Mp batch geocode new Node.js demo for batch geocoding a .csv Feb 15, 2018
@mpayson
Copy link
Contributor Author

mpayson commented Feb 15, 2018

@jgravois , yes, I'll have it done by end of week!

Side note, should we include it as part of Node CLI example #112? Then doc in a readme separate files for people looking at batch-geocoding/search/export samples? @dbouwman

@mpayson
Copy link
Contributor Author

mpayson commented Feb 15, 2018

@jgravois

  • now assumed cloned
  • added node dependency to readme. I think spread etc only requires >6.x? Can also update to support older versions?
  • config updates
    • encased un and other properties as strings, and described them in readme
    • hardcoded CSV path and the fieldmap
    • ❓ added quick fieldmap explanation in readme and added options as comments in config.js. thoughts? agreed this is confusing.
  • package.json updates
    • "private": true
    • "Apache-2.0"
    • version 1.0.2
  • remove scripts tags

Copy link
Contributor

@jgravois jgravois left a comment

Choose a reason for hiding this comment

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

object spread properties > 8.6.0

other than that, the PR looks great.

@jgravois
Copy link
Contributor

should we include it as part of Node CLI example #112?

nah, lets keep them separate. i'd like to see our collection of demos grow to include lots of different browser samples and lots of Node.js samples too.

@jgravois
Copy link
Contributor

jgravois commented Feb 22, 2018

pushed one more commit to rename the directory batch-geocoder-node and append the context to a few others and rebased.

thx again @mpayson for contributing this sweet demo!

…v in node

AFFECTS PACKAGES:
batch-geocoder
@esri/arcgis-rest-geocoder-vanilla
@esri/arcgis-rest-demo-vanilla

ISSUES CLOSED: Esri#97
@jgravois jgravois merged commit 8a596be into Esri:master Feb 22, 2018
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.

3 participants