Added cached readonly field "address" to traveler to allow search functionally and reduce database lookups

This commit is contained in:
John Mullins
2024-02-16 18:10:08 +11:00
parent 83d5874155
commit cd022fbf54
3 changed files with 10 additions and 39 deletions
+1 -24
View File
@@ -11,27 +11,4 @@ def nightly_check_active_status():
traveller.save()
for traveller in Traveller.objects.all():
if Family.objects.filter(traveller=traveller).exists():
continue
fam = Family()
fam.traveller = traveller
fam.residential_address = traveller.residential_address
fam.residential_suburb = traveller.residential_suburb
fam.postal_address = traveller.postal_address
fam.parent_A_firstname = traveller.parent_A_firstname
fam.parent_A_lastname = traveller.parent_A_lastname
fam.parent_A_phone = traveller.parent_A_phone
fam.parent_A_email = traveller.parent_A_email
fam.parent_B_firstname = traveller.parent_B_firstname
fam.parent_B_lastname = traveller.parent_B_lastname
fam.parent_B_phone = traveller.parent_B_phone
fam.parent_B_email = traveller.parent_B_email
fam.emergency_contact_A_firstname = traveller.emergency_contact_A_firstname
fam.emergency_contact_A_lastname = traveller.emergency_contact_A_lastname
fam.emergency_contact_A_phone = traveller.emergency_contact_A_phone
fam.emergency_contact_A_relation = traveller.emergency_contact_A_firstname
fam.emergency_contact_B_firstname = traveller.emergency_contact_B_firstname
fam.emergency_contact_B_lastname = traveller.emergency_contact_B_lastname
fam.emergency_contact_B_phone = traveller.emergency_contact_B_firstname
fam.emergency_contact_B_relation = traveller.emergency_contact_B_relation
fam.save()
traveller.save()