Skip to content

semantiq Rtd Provider : avoid adding default company ID if parameter is present #12985

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
8 changes: 2 additions & 6 deletions modules/semantiqRtdProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const LOG_PREFIX = '[SemantIQ RTD Module]: ';
const KEYWORDS_URL = 'https://api.adnz.co/api/ws-semantiq/page-keywords';
const STORAGE_KEY = `adnz_${SUBMODULE_NAME}`;
const AUDIENZZ_COMPANY_ID = 1;
const REQUIRED_TENANT_IDS = [AUDIENZZ_COMPANY_ID];
const FALLBACK_TENANT_IDS = [AUDIENZZ_COMPANY_ID];
const AUDIENZZ_GLOBAL_VENDOR_ID = 783;

const DEFAULT_TIMEOUT = 1000;
Expand Down Expand Up @@ -58,13 +58,9 @@ const getPageUrl = () => getWindowLocation().href;
* @returns {number[]}
*/
const getTenantIds = (companyId) => {
if (!companyId) {
return REQUIRED_TENANT_IDS;
}

const companyIdArray = Array.isArray(companyId) ? companyId : [companyId];

return [...REQUIRED_TENANT_IDS, ...companyIdArray];
return companyIdArray.filter(Boolean).length ? companyIdArray : FALLBACK_TENANT_IDS;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions test/spec/modules/semantiqRtdProvider_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ describe('semantiqRtdProvider', () => {

const requestUrl = new URL(server.requests[0].url);

expect(requestUrl.searchParams.get('tenantIds')).to.be.equal('1,13');
expect(requestUrl.searchParams.get('tenantIds')).to.be.equal('13');
});

it('allows to specify multiple company IDs as a parameter', async () => {
Expand Down Expand Up @@ -136,7 +136,7 @@ describe('semantiqRtdProvider', () => {

const requestUrl = new URL(server.requests[0].url);

expect(requestUrl.searchParams.get('tenantIds')).to.be.equal('1,13,23');
expect(requestUrl.searchParams.get('tenantIds')).to.be.equal('13,23');
});

it('gets keywords from the cache if the data is present in the storage', async () => {
Expand Down