From 8d4769d74d45e4f0ec430c0273479cddea173c2e Mon Sep 17 00:00:00 2001 From: guillermo Date: Mon, 18 Nov 2024 13:34:20 +0100 Subject: [PATCH] feat: refs #8057 More precision in getGeo --- db/routines/vn/functions/address_getGeo.sql | 1 + db/routines/vn/functions/client_getGeo.sql | 1 + db/routines/vn/functions/supplier_getGeo.sql | 1 + db/versions/11346-yellowPhormium/00-address.sql | 1 + db/versions/11346-yellowPhormium/01-client.sql | 1 + db/versions/11346-yellowPhormium/02-supplier.sql | 1 + 6 files changed, 6 insertions(+) diff --git a/db/routines/vn/functions/address_getGeo.sql b/db/routines/vn/functions/address_getGeo.sql index 0800d226a..213eb91c3 100644 --- a/db/routines/vn/functions/address_getGeo.sql +++ b/db/routines/vn/functions/address_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM address a JOIN town t ON t.provinceFk = a.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = a.postalCode OR a.postalCode IS NULL) JOIN zoneGeo zg ON zg.id = p.geoFk WHERE a.id = vSelf ORDER BY (a.city SOUNDS LIKE t.name) DESC, diff --git a/db/routines/vn/functions/client_getGeo.sql b/db/routines/vn/functions/client_getGeo.sql index e16653ee5..9c2e3212e 100644 --- a/db/routines/vn/functions/client_getGeo.sql +++ b/db/routines/vn/functions/client_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM client c JOIN town t ON t.provinceFk = c.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = c.postcode OR c.postcode IS NULL) JOIN zoneGeo zg ON zg.id = p.geoFk WHERE c.id = vSelf ORDER BY (c.city SOUNDS LIKE t.name) DESC, diff --git a/db/routines/vn/functions/supplier_getGeo.sql b/db/routines/vn/functions/supplier_getGeo.sql index 10ca5b8b8..86984272c 100644 --- a/db/routines/vn/functions/supplier_getGeo.sql +++ b/db/routines/vn/functions/supplier_getGeo.sql @@ -15,6 +15,7 @@ BEGIN FROM supplier s JOIN town t ON t.provinceFk = s.provinceFk JOIN postCode p ON p.townFk = t.id + AND (p.code = s.postCode OR s.postCode IS NULL) LEFT JOIN supplierAddress sad ON sad.supplierFk = s.id JOIN zoneGeo zg ON zg.id = p.geoFk WHERE s.id = vSelf diff --git a/db/versions/11346-yellowPhormium/00-address.sql b/db/versions/11346-yellowPhormium/00-address.sql index 6837e0d86..f91d0ae9f 100644 --- a/db/versions/11346-yellowPhormium/00-address.sql +++ b/db/versions/11346-yellowPhormium/00-address.sql @@ -10,6 +10,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tAddressGeo FROM vn.address a JOIN vn.town t ON t.provinceFk = a.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = a.postalCode OR a.postalCode IS NULL) JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY a.id ORDER BY (a.city SOUNDS LIKE t.`name`) DESC, diff --git a/db/versions/11346-yellowPhormium/01-client.sql b/db/versions/11346-yellowPhormium/01-client.sql index a95d21efa..cb6fe41e8 100644 --- a/db/versions/11346-yellowPhormium/01-client.sql +++ b/db/versions/11346-yellowPhormium/01-client.sql @@ -13,6 +13,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tClientGeo FROM vn.client c JOIN vn.town t ON t.provinceFk = c.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = c.postcode OR c.postcode IS NULL) JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY c.id ORDER BY (c.city SOUNDS LIKE t.`name`) DESC, diff --git a/db/versions/11346-yellowPhormium/02-supplier.sql b/db/versions/11346-yellowPhormium/02-supplier.sql index a28e7d680..4e866525e 100644 --- a/db/versions/11346-yellowPhormium/02-supplier.sql +++ b/db/versions/11346-yellowPhormium/02-supplier.sql @@ -12,6 +12,7 @@ CREATE OR REPLACE TEMPORARY TABLE tmp.tSupplierGeo FROM vn.supplier s JOIN vn.town t ON t.provinceFk = s.provinceFk JOIN vn.postCode p ON p.townFk = t.id + AND (p.code = s.postCode OR s.postCode IS NULL) LEFT JOIN vn.supplierAddress sad ON sad.supplierFk = s.id JOIN vn.zoneGeo zg ON zg.id = p.geoFk GROUP BY s.id