From 692c10e553349fb1e3b3907782f4ec928196e87d Mon Sep 17 00:00:00 2001 From: abhishek Date: Thu, 17 Sep 2026 11:04:37 +0530 Subject: [PATCH] partner list --- models/partner.go | 7 +++++-- repositories/partnerRepository.go | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/models/partner.go b/models/partner.go index 0707a88..129fc7f 100644 --- a/models/partner.go +++ b/models/partner.go @@ -299,8 +299,11 @@ type NewPartner struct { because the rider app reads it. The same region is also written to `partnerlocations`, which is the table that may hold SEVERAL — a partner routinely serves more than one city, and that is why the link table - exists. Nothing populates more than one today: `regionsOf` returns this - single field and the console's form offers one district, never a set. + exists, and partners with two are live — partner 44 covers regions 1 and + 2. Nothing on THIS path creates one: `regionsOf` returns this single + field and the console's form offers one district, never a set. So a + multi-region partner can be read and must be handled, but cannot yet be + made here. `GetPartners` reads the link table rather than this field, for two reasons. It is the column allowed to grow, so a partner who covers a diff --git a/repositories/partnerRepository.go b/repositories/partnerRepository.go index 1794915..963df1f 100644 --- a/repositories/partnerRepository.go +++ b/repositories/partnerRepository.go @@ -109,16 +109,18 @@ func (r *partnerRepository) GetPartners(aid, pid, uid int) ([]models.Partnerinfo // // `partnerinfo.applocationid` is the HOME region — CreatePartner writes // `regions[0]` there — while partnerlocations holds every region covered. - // Today those are always the same one region, because `regionsOf` returns a - // single district and the console's form offers one ("never a set"). So - // this is not a behaviour change yet; it is the filter being applied to the - // column that is allowed to grow. The moment a partner covers two cities, - // filtering on the home region would hide them from the second, and the - // link table is the whole reason that table exists. + // Those are not the same thing, and not only in theory: partner 44, + // Xpress-Cbe-Main, has a home region of 1 and link rows for 1 AND 2, so + // filtering on the partner row hid them from every Madurai query. That is + // the case the link table exists for. // - // DISTINCT for that same future: a partner covering three regions has three - // rows in the join and is still one partner. Only partnerinfo columns are - // selected, so there is nothing per-region for it to fail to collapse. + // DISTINCT because such a partner has one row per region in the join and is + // still one partner. Only partnerinfo columns are selected, so there is + // nothing per-region for it to fail to collapse. + // + // A caller fanning out over regions and concatenating the answers still has + // to dedupe — the same partner is legitimately in two of them. The console's + // `useAllPartners` does; it listed Xpress-Cbe-Main twice until it did. const columns = `select distinct p.partnerid,p.applocationid,p.partnertypeid,p.partnername, p.primarycontact,p.primaryemail,p.contactno,p.address,p.suburb,p.state,p.city,p.partnerimage from partnerinfo p