Skip to content

Commit

Permalink
lower default max rows to fetch for now as it returns too much data
Browse files Browse the repository at this point in the history
  • Loading branch information
diosmosis committed Feb 15, 2024
1 parent a07b41c commit 0f2d2e8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
16 changes: 11 additions & 5 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,21 @@ export function fetchAll(requests: MatomoRequestParams[], options: ApiFetchOptio
const urlFetched = urlsToFetch[i].url;
const responseIndex = allUrlsMappedToIndex[urlFetched];

const code = r.getResponseCode();

if (code >= 500
|| code === 420
) {
countOfFailedRequests += 1;
return; // retry
}

// save the response even if it's an error so we can get the server-side error message if needed
responseContents[responseIndex] = r.getContentText('UTF-8');
responseContents[responseIndex] = JSON.parse(responseContents[responseIndex] as string);

const code = r.getResponseCode();
if (code >= 500
|| code === 420
|| (responseContents[responseIndex].result === 'error'
&& !/Requested report.*not found in the list of available reports/.test(responseContents[responseIndex].message))
if (responseContents[responseIndex].result === 'error'
&& !/Requested report.*not found in the list of available reports/.test(responseContents[responseIndex].message)
) {
countOfFailedRequests += 1;
return; // retry
Expand Down
2 changes: 1 addition & 1 deletion src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const env = typeof process === 'undefined' ? null : process.env;
export default <Record<string, string>>{
DEBUG: properties.getProperty('DEBUG') || env?.DEBUG || '0',
CONFIG_REQUEST_CACHE_TTL_SECS: properties.getProperty('CONFIG_REQUEST_CACHE_TTL_SECS') || env?.CONFIG_REQUEST_CACHE_TTL_SECS || '60',
MAX_ROWS_TO_FETCH_PER_REQUEST: properties.getProperty('MAX_ROWS_TO_FETCH_PER_REQUEST') || env?.MAX_ROWS_TO_FETCH_PER_REQUEST || '50000',
MAX_ROWS_TO_FETCH_PER_REQUEST: properties.getProperty('MAX_ROWS_TO_FETCH_PER_REQUEST') || env?.MAX_ROWS_TO_FETCH_PER_REQUEST || '1000',
SCRIPT_RUNTIME_LIMIT: properties.getProperty('SCRIPT_RUNTIME_LIMIT') || env?.SCRIPT_RUNTIME_LIMIT || '350',
API_REQUEST_SOURCE_IDENTIFIER: properties.getProperty('API_REQUEST_SOURCE_IDENTIFIER') || env?.API_REQUEST_SOURCE_IDENTIFIER || 'fromLooker',
API_REQUEST_RETRY_LIMIT_IN_SECS: properties.getProperty('API_REQUEST_RETRY_LIMIT_IN_SECS') || env?.API_REQUEST_RETRY_LIMIT_IN_SECS || '120',
Expand Down

0 comments on commit 0f2d2e8

Please sign in to comment.