Skip to content

Commit

Permalink
Merge pull request #61 from Amsterdam/feature/fix-verblijfsobjecten-o…
Browse files Browse the repository at this point in the history
…rder

Fixed the order of the verblijfsobjecten in the import
  • Loading branch information
kramer65 authored Oct 26, 2020
2 parents 926c730 + 0559cb0 commit bba06b2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/bouwdossiers/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,19 @@ def add_wabo_dossier(x_dossier, file_path, import_file, count, total_count): #
# in that we only store a relave url, not the full url
bestand_str = bestand.get('URL').replace('https://conversiestraatwabo.amsterdam.nl/webDAV/', '')
if type(bestand_str) is str and len(bestand_str) > 250:
# Bestand urls longer than 250 characters are not supported by the DB. Since only one in about 200.000
# records had this problem we'll just cap that url on 250 chars. This means that url will not work, but
# we'll accept that for now.
log.warning(f'The bestand str "{bestand_str}" is more than 250 characters')
bestand_str = bestand_str[:250]
bestanden.append(bestand_str)

bestand_pad = bestand.get('oorspronkelijk_pad')
if type(bestand_pad) is str and len(bestand_pad) > 250:
log.error(f'The bestand_pad str "{bestand_pad}" is more than 250 characters')
# Bestand_pads longer than 250 characters are not supported by the DB. Since only one in about 200.000
# records had this problem we'll just cap that pad on 250 chars. This means that pad will not work, but
# we'll accept that for now.
log.warning(f'The bestand_pad str "{bestand_pad}" is more than 250 characters')
bestand_pad = bestand_pad[:250]
bestanden_pads.append(bestand_pad)

Expand Down Expand Up @@ -462,22 +468,23 @@ def add_bag_ids_to_pre_wabo():
SELECT
ba.id,
ARRAY_AGG(DISTINCT bp.landelijk_id) AS panden,
ARRAY_AGG(DISTINCT bv.landelijk_id) AS vbos,
ARRAY_AGG(bv.landelijk_id) AS verblijfsobjecten,
ARRAY_AGG(bv._openbare_ruimte_naam || ' ' || bv._huisnummer || bv._huisletter ||
CASE WHEN (bv._huisnummer_toevoeging = '') IS NOT FALSE THEN '' ELSE '-' || bv._huisnummer_toevoeging
END) AS vbos_label
END) AS verblijfsobjecten_label
FROM bouwdossiers_adres ba
JOIN bag_verblijfsobject bv ON ba.straat = bv._openbare_ruimte_naam
AND ba.huisnummer_van = bv._huisnummer
JOIN bag_verblijfsobjectpandrelatie bvbo ON bvbo.verblijfsobject_id = bv.id
JOIN bag_pand bp on bp.id = bvbo.pand_id
JOIN bouwdossiers_bouwdossier bb ON bb.id = ba.bouwdossier_id
WHERE bb.source = 'EDEPOT'
GROUP BY ba.id)
GROUP BY ba.id
)
UPDATE bouwdossiers_adres
SET panden = adres_pand.panden,
verblijfsobjecten = adres_pand.vbos,
verblijfsobjecten_label = adres_pand.vbos_label
verblijfsobjecten = adres_pand.verblijfsobjecten,
verblijfsobjecten_label = adres_pand.verblijfsobjecten_label
FROM adres_pand
WHERE bouwdossiers_adres.id = adres_pand.id
""")
Expand Down

0 comments on commit bba06b2

Please sign in to comment.