mdb / node-phli

A Node.js module for interacting with the City of Philadelphia's Licenses & Inspections data.
6 stars 1 forks source link

Can we get a limited, counted set of cases? #4

Open gsf opened 11 years ago

gsf commented 11 years ago

The "cases" type currently hits http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails, which is busted if you try to pass "$top" or "$inlinecount". Is there a way to limit and get counts for the preview?

timwis commented 11 years ago

http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$top=5&$inlinecount=allpages is working fine for me...are you getting an error?

mdb commented 11 years ago

@timwis Your URL works for me.

@gsf Does @timwis's response address your question? Is this an invalid issue?

mdb commented 11 years ago

@timwis While your URL works for me, I've observed the following. Am I missing something obvious?

Does not work: http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$expand=cases,locations&$top=&$inlinecount=

Works: http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$top=&$inlinecount=

I think we're a bit confused as to when we should be including $expand=cases,locations. Currently, we include this on every getCases call, yet its inclusion seemingly results in a timeout.

Could you please clarify?

timwis commented 11 years ago

Interesting...so you can either include the &$expand= or the &$top= but when you include both it times out. I could have sworn I tested this before and it worked. I can report this as a bug then. Before I do, are there any other bugs you've come across that I should include?

mdb commented 11 years ago

@timwis Actually, I'm not sure if $expand=cases,locations works at all, unless I'm mistaken.

For example, even the following -- which has no $top -- seemingly does not work: http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$expand=cases,locations

I was fairly sure we tested too.

And just to clarify, the end goal here is to write a 'getCases' method that returns cases as we discussed at RHoK. If I'm off-base, please steer me back on course; I'm not sure I ever fully grokked cases to begin with.

timwis commented 11 years ago

FYI, I've submitted this ticket to our support system in the City. Before I did it, though, I think I narrowed it down further. The issue is not to do with the $top parameter; rather with expanding cases.

It seems like whenever we expand cases, it often leads to a timeout. For instance, this always times out: http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$filter=locations/census_tract%20eq%20'162'&$expand=cases&$top=5

But when we expand locations instead of cases, it works fine: http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$filter=locations/census_tract%20eq%20'162'&$expand=locations&$top=5

mdb commented 11 years ago

Great - thanks Tim. I'll stay posted.

mdb commented 11 years ago

@timwis - Do you have any update on this? Thanks.

timwis commented 11 years ago

Mike, I followed up on this on 1/16, and could have sworn I replied here to let you know. My bad. I just followed up again today. The latest status is:

The expand part of the URI query works as expected:

http://services.phila.gov/PhillyApi/Data/v0.7/Service.svc/violationdetails?$format=json&$filter=locations/census_tract%20eq%20'162'&$expand=cases

The timeout occurs when top 5 records are requested when specifying the "top" operator.

The are investigating what's causing this behavior, and keep you informed of our findings.

mdb commented 11 years ago

Great - thanks Tim. I'll stay posted.

caseycesari commented 11 years ago

@timwis any update on this? Was using the API recently and noticed that for permits, $expand=locations, works fine, but if you try and $expand=zoningboardappeals or $expand=buildingboardappeals, both of which are 'deferred' properties on a permit, you get an Oracle error. For example:

Works: http://services.phila.gov/PhillyAPI/Data/v0.7/Service.svc/permits('333274')?$expand=locations

Doesn't work: http://services.phila.gov/PhillyAPI/Data/v0.7/Service.svc/permits('333274')?$expand=zoningboardappeals