more fixes

This commit is contained in:
2026-03-18 04:39:48 -04:00
parent 885b9b5e44
commit 00375c2926
4 changed files with 137 additions and 132 deletions

View File

@ -1016,7 +1016,7 @@
" JOIN agreego.entity entity_8 ON entity_8.id = address_7.id",
" WHERE",
" NOT entity_8.archived",
" AND relationship_5.target_id = address_7.id),",
" AND relationship_5.target_id = entity_8.id),",
" 'type', entity_6.type",
" )), '[]'::jsonb)",
" FROM agreego.contact contact_4",
@ -1024,7 +1024,7 @@
" JOIN agreego.entity entity_6 ON entity_6.id = relationship_5.id",
" WHERE",
" NOT entity_6.archived",
" AND contact_4.source_id = entity_3.id),",
" AND relationship_5.source_id = entity_3.id),",
" 'age', person_1.age,",
" 'archived', entity_3.archived,",
" 'contacts',",
@ -1048,7 +1048,7 @@
" JOIN agreego.entity entity_17 ON entity_17.id = address_16.id",
" WHERE",
" NOT entity_17.archived",
" AND relationship_10.target_id = address_16.id))",
" AND relationship_10.target_id = entity_17.id))",
" WHEN entity_11.target_type = 'email_address' THEN",
" ((SELECT jsonb_build_object(",
" 'address', email_address_14.address,",
@ -1062,7 +1062,7 @@
" JOIN agreego.entity entity_15 ON entity_15.id = email_address_14.id",
" WHERE",
" NOT entity_15.archived",
" AND relationship_10.target_id = email_address_14.id))",
" AND relationship_10.target_id = entity_15.id))",
" WHEN entity_11.target_type = 'phone_number' THEN",
" ((SELECT jsonb_build_object(",
" 'archived', entity_13.archived,",
@ -1076,7 +1076,7 @@
" JOIN agreego.entity entity_13 ON entity_13.id = phone_number_12.id",
" WHERE",
" NOT entity_13.archived",
" AND relationship_10.target_id = phone_number_12.id))",
" AND relationship_10.target_id = entity_13.id))",
" ELSE NULL END,",
" 'type', entity_11.type",
" )), '[]'::jsonb)",
@ -1085,7 +1085,7 @@
" JOIN agreego.entity entity_11 ON entity_11.id = relationship_10.id",
" WHERE",
" NOT entity_11.archived",
" AND contact_9.source_id = entity_3.id),",
" AND relationship_10.source_id = entity_3.id),",
" 'created_at', entity_3.created_at,",
" 'email_addresses',",
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
@ -1107,7 +1107,7 @@
" JOIN agreego.entity entity_22 ON entity_22.id = email_address_21.id",
" WHERE",
" NOT entity_22.archived",
" AND relationship_19.target_id = email_address_21.id),",
" AND relationship_19.target_id = entity_22.id),",
" 'type', entity_20.type",
" )), '[]'::jsonb)",
" FROM agreego.contact contact_18",
@ -1115,7 +1115,7 @@
" JOIN agreego.entity entity_20 ON entity_20.id = relationship_19.id",
" WHERE",
" NOT entity_20.archived",
" AND contact_18.source_id = entity_3.id),",
" AND relationship_19.source_id = entity_3.id),",
" 'first_name', person_1.first_name,",
" 'id', entity_3.id,",
" 'last_name', person_1.last_name,",
@ -1140,7 +1140,7 @@
" JOIN agreego.entity entity_27 ON entity_27.id = phone_number_26.id",
" WHERE",
" NOT entity_27.archived",
" AND relationship_24.target_id = phone_number_26.id),",
" AND relationship_24.target_id = entity_27.id),",
" 'type', entity_25.type",
" )), '[]'::jsonb)",
" FROM agreego.contact contact_23",
@ -1148,7 +1148,7 @@
" JOIN agreego.entity entity_25 ON entity_25.id = relationship_24.id",
" WHERE",
" NOT entity_25.archived",
" AND contact_23.source_id = entity_3.id),",
" AND relationship_24.source_id = entity_3.id),",
" 'type', entity_3.type",
")",
"FROM agreego.person person_1",
@ -1253,7 +1253,7 @@
" JOIN agreego.entity entity_8 ON entity_8.id = address_7.id",
" WHERE",
" NOT entity_8.archived",
" AND relationship_5.target_id = address_7.id),",
" AND relationship_5.target_id = entity_8.id),",
" 'type', entity_6.type",
" )), '[]'::jsonb)",
" FROM agreego.contact contact_4",
@ -1261,7 +1261,7 @@
" JOIN agreego.entity entity_6 ON entity_6.id = relationship_5.id",
" WHERE",
" NOT entity_6.archived",
" AND contact_4.source_id = entity_3.id),",
" AND relationship_5.source_id = entity_3.id),",
" 'age', person_1.age,",
" 'archived', entity_3.archived,",
" 'contacts',",
@ -1285,7 +1285,7 @@
" JOIN agreego.entity entity_17 ON entity_17.id = address_16.id",
" WHERE",
" NOT entity_17.archived",
" AND relationship_10.target_id = address_16.id))",
" AND relationship_10.target_id = entity_17.id))",
" WHEN entity_11.target_type = 'email_address' THEN",
" ((SELECT jsonb_build_object(",
" 'address', email_address_14.address,",
@ -1299,7 +1299,7 @@
" JOIN agreego.entity entity_15 ON entity_15.id = email_address_14.id",
" WHERE",
" NOT entity_15.archived",
" AND relationship_10.target_id = email_address_14.id))",
" AND relationship_10.target_id = entity_15.id))",
" WHEN entity_11.target_type = 'phone_number' THEN",
" ((SELECT jsonb_build_object(",
" 'archived', entity_13.archived,",
@ -1313,7 +1313,7 @@
" JOIN agreego.entity entity_13 ON entity_13.id = phone_number_12.id",
" WHERE",
" NOT entity_13.archived",
" AND relationship_10.target_id = phone_number_12.id))",
" AND relationship_10.target_id = entity_13.id))",
" ELSE NULL END,",
" 'type', entity_11.type",
" )), '[]'::jsonb)",
@ -1323,7 +1323,7 @@
" WHERE",
" NOT entity_11.archived",
" AND contact_9.is_primary = ($11#>>'{}')::boolean",
" AND contact_9.source_id = entity_3.id),",
" AND relationship_10.source_id = entity_3.id),",
" 'created_at', entity_3.created_at,",
" 'email_addresses',",
" (SELECT COALESCE(jsonb_agg(jsonb_build_object(",
@ -1345,7 +1345,7 @@
" JOIN agreego.entity entity_22 ON entity_22.id = email_address_21.id",
" WHERE",
" NOT entity_22.archived",
" AND relationship_19.target_id = email_address_21.id),",
" AND relationship_19.target_id = entity_22.id),",
" 'type', entity_20.type",
" )), '[]'::jsonb)",
" FROM agreego.contact contact_18",
@ -1353,7 +1353,7 @@
" JOIN agreego.entity entity_20 ON entity_20.id = relationship_19.id",
" WHERE",
" NOT entity_20.archived",
" AND contact_18.source_id = entity_3.id),",
" AND relationship_19.source_id = entity_3.id),",
" 'first_name', person_1.first_name,",
" 'id', entity_3.id,",
" 'last_name', person_1.last_name,",
@ -1379,7 +1379,7 @@
" WHERE",
" NOT entity_27.archived",
" AND phone_number_26.number ILIKE $32#>>'{}'",
" AND relationship_24.target_id = phone_number_26.id),",
" AND relationship_24.target_id = entity_27.id),",
" 'type', entity_25.type",
" )), '[]'::jsonb)",
" FROM agreego.contact contact_23",
@ -1387,7 +1387,7 @@
" JOIN agreego.entity entity_25 ON entity_25.id = relationship_24.id",
" WHERE",
" NOT entity_25.archived",
" AND contact_23.source_id = entity_3.id),",
" AND relationship_24.source_id = entity_3.id),",
" 'type', entity_3.type",
")",
"FROM agreego.person person_1",
@ -1457,7 +1457,7 @@
" JOIN agreego.entity entity_5 ON entity_5.id = phone_number_4.id",
" WHERE",
" NOT entity_5.archived",
" AND relationship_2.target_id = phone_number_4.id",
" AND relationship_2.target_id = entity_5.id",
" ),",
" 'type', entity_3.type",
")",