NYCPlanning / deprecated-labs-zap-api

Deprecated version of the ZAP API, see https://github.com/NYCPlanning/labs-zap-api
Other
5 stars 3 forks source link

511: new migration to update materialized view to remove future milestone dates #125

Closed trbmcginnis closed 5 years ago

trbmcginnis commented 5 years ago

Some projects have future milestone dates. In order to avoid these future dates from showing up on the projects list, I added this to the WHERE clause on dcp_milestoneproject table in materialized view:

AND mm.dcp_actualenddate::date <= CURRENT_DATE

This way, any milestone dates that are less than or equal to the current date (in the past or the present) will be included in the materialized view.

I then re-added the dcp_name_index to normalized_projects, as this index is removed when the materialized view is dropped and then re-created.

I did this index creation in a separate migration to make it cleaner/easier to remember for future updates, and to make it easier to run. I was having trouble getting the materialized view to run before creating the new indices when they were in the same migration--there's probably a way around this rather than creating a whole new migration--but creating a new migration seemed like the best solution.