Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/controllers/llmo/llmo-referral-traffic.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,11 @@ export function createReferralTrafficBusinessImpactHandler(getSiteAndValidateAcc
* Business Impact (adobe_analytics, ga4) has its own DRS provider check and is
* intentionally excluded here.
*
* Order matters: optel is listed first because it is the preferred source.
* Order matters: cdn is listed first because it is the preferred source.
* The has-data response preserves this order in availableSources so callers
* can pick the first entry as the active source (optel wins over cdn).
* can pick the first entry as the active source (cdn wins over optel).
*/
const TRAFFIC_INSIGHTS_SOURCES = ['optel', 'cdn'];
const TRAFFIC_INSIGHTS_SOURCES = ['cdn', 'optel'];
const TRAFFIC_INSIGHTS_TABLES = TRAFFIC_INSIGHTS_SOURCES.map((s) => SOURCE_TO_TABLE[s]);

/**
Expand All @@ -767,8 +767,8 @@ const TRAFFIC_INSIGHTS_TABLES = TRAFFIC_INSIGHTS_SOURCES.map((s) => SOURCE_TO_TA
* { hasData: boolean, availableSources: Array<'optel'|'cdn'> }
*
* availableSources lists whichever of optel/cdn has at least one row, in
* priority order (optel first). Callers should use the first entry as the
* active source so they naturally prefer optel over cdn.
* priority order (cdn first). Callers use the first entry as the active
* source, which now prefers cdn over optel.
* hasData is true iff availableSources is non-empty.
*
* Both tables are checked in parallel with limit(1) — no RPC required.
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/llmo/llmo-referral-traffic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ describe('llmo-referral-traffic', () => {
expect(body.availableSources).to.deep.equal(['cdn']);
});

it('returns hasData:true and availableSources:["optel","cdn"] when both have records', async () => {
it('returns hasData:true and availableSources:["cdn","optel"] when both have records', async () => {
const client = makeHasDataChainClient({
referral_traffic_optel: { data: [ROW], error: null },
referral_traffic_cdn: { data: [ROW], error: null },
Expand All @@ -1098,7 +1098,7 @@ describe('llmo-referral-traffic', () => {
expect(res.status).to.equal(200);
const body = await res.json();
expect(body.hasData).to.equal(true);
expect(body.availableSources).to.deep.equal(['optel', 'cdn']);
expect(body.availableSources).to.deep.equal(['cdn', 'optel']);
});

it('returns hasData:false and availableSources:[] when both tables are empty', async () => {
Expand Down
Loading