Created
July 23, 2012 14:36
-
-
Save andrewxhill/3163949 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GET_PROJECTS_QUERY_TEMPLATE: "WITH qu AS ( " + | |
" SELECT " + | |
" P.nexso_code, COUNT(S.cartodb_id) AS solution_count, P.cartodb_id AS project_id, P.title, P.approval_date, P.fixed_approval_date, P.external_project_url, " + | |
" P.location_verbatim, T.name AS topic_name, P.solution_id AS solution_id, P.budget, S.name AS solution_name, S.nexso_url AS solution_url, " + | |
" A.external_url AS agency_url, A.name AS agency_name, ST_AsGeoJSON(A.the_geom) AS agency_position, " + | |
" PWA.the_geom " + | |
" FROM " + | |
" v3_projects P LEFT JOIN v1_solutions S ON (P.solution_id = S.cartodb_id) " + | |
" LEFT JOIN v1_agencies A ON (P.agency_id = A.cartodb_id) "+ | |
" LEFT JOIN v1_topics AS T ON (P.topic_id = T.cartodb_id), " + | |
" v3_project_work_areas AS PWA " + | |
" WHERE " + | |
" P.nexso_code != 'RG-M1016' AND P.cartodb_id = PWA.project_id AND <%= topicsCondition %> <%= solutionCondition %>" + | |
" (EXTRACT(YEAR FROM P.fixed_approval_date) >= <%= startYear %> AND " + | |
" EXTRACT(YEAR FROM P.fixed_approval_date) <= <%= endYear %> OR (EXTRACT(YEAR FROM P.fixed_approval_date) < 2002)) " + | |
") " + | |
"SELECT " + | |
" nexso_code, solution_count, project_id, title, approval_date, fixed_approval_date, external_project_url, " + | |
" location_verbatim, topic_name, budget, agency_name, agency_url, the_geom, agency_position, solution_id, solution_name, solution_url, " + | |
" ST_X(ST_Centroid(the_geom)) AS pwa_lon, " + | |
" ST_Y(ST_Centroid(the_geom)) AS pwa_lat, " + | |
"FROM qu " + | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment