def save(self, batch_size, fuzzy_match, match_threshold): self.remove_ambiguous_addresses_by_address() addressbase_data = get_uprn_hash_table(self.council_ids) self.handle_invalid_uprns(addressbase_data, fuzzy_match, match_threshold) self.attach_doorstep_gridrefs(addressbase_data) self.remove_addresses_outside_target_auth() self.remove_ambiguous_addresses_by_uprn() self.report_duplicate_uprns() addresses_db = [] for address in self.elements: record = ResidentialAddress( address=address["address"], postcode=address["postcode"], polling_station_id=address["polling_station_id"], council=address["council"], slug=address["slug"], uprn=address["uprn"], location=address.get("location", None), ) addresses_db.append(record) ResidentialAddress.objects.bulk_create(addresses_db, batch_size=batch_size)
def save(self, batch_size): addresses_db = [] for address in self: record = ResidentialAddress( address=address.address, postcode=re.sub('[^A-Z0-9]', '', address.postcode), polling_station_id=address.polling_station_id, council_id=address.council_id, slug=address.slug, ) addresses_db.append(record) ResidentialAddress.objects.bulk_create( addresses_db, batch_size=batch_size)
def save(self, batch_size): addresses_db = [] for address in self: record = ResidentialAddress( address=address.address, postcode=Postcode(address.postcode).without_space, polling_station_id=address.polling_station_id, council_id=address.council_id, slug=address.slug, uprn=address.uprn, location=address.location, ) addresses_db.append(record) ResidentialAddress.objects.bulk_create(addresses_db, batch_size=batch_size)
def save(self, batch_size): self.elements = self.remove_ambiguous_addresses() addresses_db = [] for address in self.elements: record = ResidentialAddress( address=address.address, postcode=address.postcode, polling_station_id=address.polling_station_id, council=address.council, slug=address.slug, ) addresses_db.append(record) ResidentialAddress.objects.bulk_create(addresses_db, batch_size=batch_size)
def save(self, batch_size): self.elements = self.remove_ambiguous_addresses() addressbase_data = self.get_uprns_from_addressbase() self.elements = self.remove_invalid_uprns(addressbase_data) self.elements = self.attach_doorstep_gridrefs(addressbase_data) self.elements = self.remove_addresses_outside_target_auth() addresses_db = [] for address in self.elements: record = ResidentialAddress( address=address.address, postcode=address.postcode, polling_station_id=address.polling_station_id, council=address.council, slug=address.slug, uprn=address.uprn, location=address.location, ) addresses_db.append(record) ResidentialAddress.objects.bulk_create(addresses_db, batch_size=batch_size)