500 error on locations endpoint when using metadata=true query param
sethvincent opened this issue · 4 comments
When making requests with the metadata=true
query param on the staging locations endpoint, I'm seeing a 500 response. The endpoint works as expected with the metadata
query param removed.
So far I haven't been able to replicate this locally, but will try some more.
@jflasher if I can't replicate it locally we may need to check out the staging logs to see what's going on with that endpoint.
Hi @sethvincent you should be getting a notice from Papertrail about access.
https://papertrailapp.com/systems/openaq-api-staging/events will be what you want to check out. Olaf also has access and can add other users if needed.
@jflasher awesome, thank you!
OK the error is:
relation "latest_locations_metadata" does not exist stack: Error: select "locations".*, "latest_locations_metadata"."data" as "metadata", "latest_locations_metadata"."version" as "metadataVersion", "latest_locations_metadata"."userId" as "metadataUserId", "latest_locations_metadata"."updatedAt" as "metadataUpdatedAt", "latest_locations_metadata"."completeness" as "metadataCompleteness" from "locations" left join "latest_locations_metadata" on "locations"."id" = "latest_locations_metadata"."locationId" where (data->>'activationDate' BETWEEN $1 AND $2 and ("completeness" between $3 and $4 or "completeness" is null) and (
My guess (if I understand correctly how the architecture works) is that there was actually something wrong with the migration file in the openaq-fetch repo. I've made a pr that makes sure it is exactly the same as in openaq-api. Somehow I managed to make the openaq-fetch migration file slightly different to the one in this repo when I reduced the metadata migrations down to one file. 🤦♂️
Here's a pr for that fix: openaq/openaq-fetch#622
Reran new migration, confirmed table and view now exist.