Last active
May 1, 2020 08:54
-
-
Save jbothma/830a6360dbd7922d621954c8a1df8f8f to your computer and use it in GitHub Desktop.
Populate Cargografias template from django-popolo SQL
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
select p.family_name as "Apellido", | |
p.given_name as "Nombre", | |
p.gender as "sexo", | |
'' as "cargoTipo", | |
'' as "cargoClase", | |
m.role as "cargoNominal", | |
o.name as "Organizacion", | |
'' as "parentOrg", | |
'' as "duracionCargo", | |
a.name as territorio, | |
'' as fechaInicioYear, | |
m.start_date as "fechaInicio", | |
'' as fuenteDeDatosInicio, | |
'' as urlFuenteInicio, | |
'' as calidadDelDatoInicio, | |
'' as fechaFinYear, | |
m.end_date as "fechaFin", | |
'' as fuenteDeDatosFin, | |
'' as urlFuenteFin, | |
'' as calidadDelDatoFin, | |
'' as partido, | |
'' as partidoGeneral, | |
'South African ID' as documentoTipo, | |
i.identifier as nroDeDoc, | |
p.image as urlFoto, | |
'' as areaId, | |
'' as patrimTotal, | |
'' as patrimUrl, | |
p.birth_date as nacimiento, | |
p.death_date as muerte | |
from popolo_person p | |
join popolo_membership m_assembly on (p.id = m_assembly.person_id) | |
join popolo_organization o_assembly on (m_assembly.organization_id = o_assembly.id) | |
join popolo_membership m on (p.id = m.person_id) | |
join popolo_organization o on (m.organization_id = o.id) | |
left outer join popolo_area a on (m.area_id = a.id) | |
left outer join popolo_identifier i on (p.id = i.object_id) | |
where o_assembly.name = 'National Assembly' | |
and o.classification not in ('Election List', 'Constituency Office', 'Party') | |
and i.scheme = 'elections_2019'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment