GreenInfo-Network / nyc-crash-mapper

React Redux web application for viewing, filtering, & comparing trends of automobile collision data published by the NYPD.
http://www.crashmapper.org
MIT License
16 stars 4 forks source link

Some intersections making bad queries? #78

Closed danrademacher closed 6 years ago

danrademacher commented 6 years ago

Looks like some intersections are making bad queries?

image

Here's the api link it tried:

https://chekpeds.carto.com/api/v2/sql?q=SELECT%20COUNT(c.cartodb_id)%20as%20total_crashes%2C%20SUM(c.number_of_cyclist_injured)%20as%20cyclist_injured%2C%20SUM(c.number_of_cyclist_killed)%20as%20cyclist_killed%2C%20SUM(c.number_of_motorist_injured)%20as%20motorist_injured%2C%20SUM(c.number_of_motorist_killed)%20as%20motorist_killed%2C%20SUM(c.number_of_pedestrian_injured)%20as%20pedestrian_injured%2C%20SUM(c.number_of_pedestrian_killed)%20as%20pedestrian_killed%2C%20SUM(c.number_of_pedestrian_injured%20%2B%20c.number_of_cyclist_injured%20%2B%20c.number_of_motorist_injured)%20as%20persons_injured%2C%20SUM(c.number_of_pedestrian_killed%20%2B%20c.number_of_cyclist_killed%20%2B%20c.number_of_motorist_killed)%20as%20persons_killed%20FROM%20crashes_all_prod%20c%20JOIN%20nyc_intersections%20a%20ON%20ST_Within(c.the_geom%2C%20a.the_geom)%20WHERE%20(%20year%3A%3Atext%20%7C%7C%20LPAD(month%3A%3Atext%2C%202%2C%20%270%27)%20%3C%3D%20%272017%27%20%7C%7C%20LPAD(12%3A%3Atext%2C%202%2C%20%270%27)%20)%20AND%20(%20year%3A%3Atext%20%7C%7C%20LPAD(month%3A%3Atext%2C%202%2C%20%270%27)%20%3E%3D%20%272015%27%20%7C%7C%20LPAD(12%3A%3Atext%2C%202%2C%20%270%27)%20)%20%20AND%20(%20number_of_cyclist_injured%20%3E%200%20OR%20number_of_motorist_injured%20%3E%200%20OR%20number_of_pedestrian_injured%20%3E%200%20%20OR%20%20number_of_cyclist_killed%20%3E%200%20OR%20number_of_motorist_killed%20%3E%200%20OR%20number_of_pedestrian_killed%20%3E%200%20)%20AND%20a.cartodb_id%20%3D%20LINDEN%20BOULEVARD%20%26%20ROCKAWAY%20PARKWAY

and the error: {"error":["syntax error at or near \"BOULEVARD\""]}

But the same intersection works on chart view: http://localhost:8889/?cfat=true&cinj=true&geo=intersection&mfat=true&minj=true&p1end=2017-12&p1start=2015-12&p2end=2015-12&p2start=2014-12&pfat=true&pinj=true&reference=citywide&secondary=LINDEN%20BOULEVARD%20%26%20ROCKAWAY%20PARKWAY%7C861&view=compare

gregallensworth commented 6 years ago

I fixed this same issue yesterday (commit 0117f17524c6f5aee2cc5e48663dea52f7591890) and confirm it working now. The fix was specifically that the intersection name-and-id were being split inappropriately (per later changes) and the name was being used, which is what I see in that SQL query.

This commit was later than our conversation yesterday, and your copy of nyc-crash-mapper gda-intersections may be outdated?

The link provided is to a Chart, not a Map. Could you pull the latest, then try it again? If it still gives you trouble, post me the resulting Map link?

danrademacher commented 6 years ago

Ok, got to confirming this. Pulled both Map and Chart code. Still seeing error: http://localhost:8080/#/?cfat=true&cinj=true&endDate=2017-12&geo=intersection&identifier=861%7CLINDEN%20BOULEVARD%20%26%20ROCKAWAY%20PARKWAY&lat=40.652830617837694&lng=-73.91135931015015&lngLats=%255B%255D&mfat=true&minj=true&noInjFat=false&pfat=true&pinj=true&startDate=2015-12&zoom=16

from console

["syntax error at or near "BOULEVARD""]0: "syntax error at or near "BOULEVARD""length: 1__proto__: Array(0)
(anonymous) @ index.js:182
trigger @ cartodb.js:6
error @ cartodb.js:20
(anonymous) @ cartodb.js:20
(anonymous) @ cartodb.js:20
b @ cartodb.js:19
error @ cartodb.js:19
l @ cartodb.js:3
fireWith @ cartodb.js:3
d @ cartodb.js:5
d @ cartodb.js:5
XMLHttpRequest.send (async)
send @ cartodb.js:5
ajax @ cartodb.js:5
_requestPOST @ cartodb.js:19
_createMap @ cartodb.js:19
(anonymous) @ cartodb.js:19
setTimeout (async)
createMap @ cartodb.js:19
getTiles @ cartodb.js:20
__update @ cartodb.js:20
onLayerDefinitionUpdated @ cartodb.js:20
invalidate @ cartodb.js:20
setLayer @ cartodb.js:20
set @ cartodb.js:19
setInteractivity @ cartodb.js:19
addInfowindow @ cartodb.js:22
initCartoSubLayerInfowindows @ index.js:224
(anonymous) @ index.js:191
trigger @ cartodb.js:6
c @ cartodb.js:23
(anonymous) @ cartodb.js:23
(anonymous) @ cartodb.js:23
(anonymous) @ cartodb.js:6
setTimeout (async)
x.delay @ cartodb.js:6
x.defer @ cartodb.js:6
c @ cartodb.js:23
cartodb.createLayer @ cartodb.js:23
initCartoLayer @ index.js:178
initMap @ index.js:163
componentDidMount @ index.js:45
(anonymous) @ ReactCompositeComponent.js:265
measureLifeCyclePerf @ ReactCompositeComponent.js:75
(anonymous) @ ReactCompositeComponent.js:264
notifyAll @ CallbackQueue.js:76
close @ ReactReconcileTransaction.js:80
closeAll @ Transaction.js:206
perform @ Transaction.js:153
batchedMountComponentIntoNode @ ReactMount.js:126
perform @ Transaction.js:140
batchedUpdates @ ReactDefaultBatchingStrategy.js:62
batchedUpdates @ ReactUpdates.js:97
_renderNewRootComponent @ ReactMount.js:320
_renderSubtreeIntoContainer @ ReactMount.js:401
render @ ReactMount.js:422
Object.defineProperty.value @ index.js:23
__webpack_require__ @ bootstrap bf5bb8082faf901b8aa9:52
(anonymous) @ spin.js:302
__webpack_require__ @ bootstrap bf5bb8082faf901b8aa9:52
webpackJsonpCallback @ bootstrap bf5bb8082faf901b8aa9:23
(anonymous) @ bundle.7b7e8b3cf94af26ed768.js:1

Reproduce with the following steps:

  1. Load this link: http://localhost:8080/#/?cfat=true&cinj=true&endDate=2017-12&geo=intersection&lat=40.652830617837694&lng=-73.91135931015015&lngLats=%255B%255D&mfat=true&minj=true&noInjFat=false&pfat=true&pinj=true&startDate=2015-12&zoom=16

  2. Select the intersection circled here in red: image

danrademacher commented 6 years ago

Just confirmed this is now working -- issue caused by names being in flux and also used as IDs.