Skip to content

Commit

Permalink
correct use of AddColumnsProcessedMetricsGoal filter (#53)
Browse files Browse the repository at this point in the history
* correctly use AddColumnsProcessedMetricsGoal (idGoal must be sent as 0 for every goal metric to be calculated)

* make sure reportParams can override idGoal if needed, and update some expected API output files

* do not forward idGoal if requesting a Goals API method + update expected files
  • Loading branch information
diosmosis committed Apr 26, 2024
1 parent b4fb373 commit f906803
Show file tree
Hide file tree
Showing 19 changed files with 525 additions and 519 deletions.
14 changes: 10 additions & 4 deletions src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,8 @@ function getReportData(request: GoogleAppsScript.Data_Studio.Request<ConnectorPa
let hasMoreRowsToFetch = true;
while (hasMoreRowsToFetch) {
const limitToUse = filter_truncate < 0 || filter_truncate >= rowsToFetchAtATime ? rowsToFetchAtATime : filter_truncate;
let partialResponseRaw = Api.fetch<DataTableRow[]|Record<string, DataTableRow[]>>(`${reportParams.apiModule}.${reportParams.apiAction}`, {

const params: Record<string, string> = {
...reportParams,
idSite: `${idSite}`,
period,
Expand All @@ -257,10 +258,15 @@ function getReportData(request: GoogleAppsScript.Data_Studio.Request<ConnectorPa
filter_truncate: filter_truncate <= 0 ? undefined : `${filter_truncate - 1}`,
filter_limit: `${limitToUse}`,
filter_offset: `${offset}`,
filter_show_goal_columns_process_goals: '1',
filter_update_columns_when_show_all_goals: '1',
showColumns,
}, {
};

if (reportParams.apiModule !== 'Goals') {
params.filter_update_columns_when_show_all_goals = '1';
params.idGoal = '0'; // calculate extra metrics for all goals
}

let partialResponseRaw = Api.fetch<DataTableRow[]|Record<string, DataTableRow[]>>(`${reportParams.apiModule}.${reportParams.apiAction}`, params, {
checkRuntimeLimit: true,
runtimeLimitAbortMessage: pastScriptRuntimeLimitErrorMessage,
});
Expand Down
24 changes: 12 additions & 12 deletions tests/appscript/expected/data_Actions.getEntryPageTitles.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,22 @@
"1228",
"0.79",
"0",
"2",
"0",
"0",
"0",
"0",
"0",
"9",
"0",
"0",
"14",
"0",
"0",
"3",
"0",
"0",
"3",
"0",
"0",
"0",
Expand All @@ -262,8 +267,10 @@
"0",
"0",
"0",
"0.01",
"0",
"0",
"0.01",
"0",
"0",
"0",
Expand All @@ -275,19 +282,12 @@
"0",
"0",
"0",
"0.001",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0046",
"0.0071",
"0.0015",
"0.0015",
"0"
]
}
Expand Down
24 changes: 12 additions & 12 deletions tests/appscript/expected/data_Actions.getEntryPageUrls.json
Original file line number Diff line number Diff line change
Expand Up @@ -240,17 +240,22 @@
"1283",
"0.76",
"0",
"3",
"0",
"0",
"0",
"0",
"0",
"9",
"0",
"0",
"15",
"0",
"0",
"3",
"0",
"0",
"3",
"0",
"0",
"0",
Expand All @@ -262,8 +267,10 @@
"0",
"0",
"0",
"0.01",
"0",
"0",
"0.01",
"0",
"0",
"0",
Expand All @@ -275,19 +282,12 @@
"0",
"0",
"0",
"0.0013",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.004",
"0.0066",
"0.0013",
"0.0013",
"0"
]
}
Expand Down
24 changes: 12 additions & 12 deletions tests/appscript/expected/data_Actions.getPageTitles.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,22 @@
"0.79",
"0.78",
"0",
"3",
"0",
"0",
"0",
"0",
"0",
"9",
"0",
"0",
"14",
"0",
"0",
"3",
"0",
"0",
"3",
"0",
"0",
"0",
Expand All @@ -242,27 +247,22 @@
"0",
"0",
"0",
"0.01",
"0",
"0.01",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0014",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0043",
"0.0067",
"0.0014",
"0.0014",
"0"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,22 @@
"0.79",
"0.78",
"0",
"3",
"0",
"0",
"0",
"0",
"0",
"9",
"0",
"0",
"14",
"0",
"0",
"3",
"0",
"0",
"3",
"0",
"0",
"0",
Expand All @@ -242,27 +247,22 @@
"0",
"0",
"0",
"0.01",
"0",
"0.01",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0014",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0043",
"0.0067",
"0.0014",
"0.0014",
"0"
]
}
Expand Down
24 changes: 12 additions & 12 deletions tests/appscript/expected/data_Actions.getPageUrls.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,22 @@
"0.76",
"0.76",
"0",
"3",
"0",
"0",
"0",
"0",
"0",
"9",
"0",
"0",
"15",
"0",
"0",
"3",
"0",
"0",
"3",
"0",
"0",
"0",
Expand All @@ -242,27 +247,22 @@
"0",
"0",
"0",
"0.01",
"0",
"0.01",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0013",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.004",
"0.0066",
"0.0013",
"0.0013",
"0"
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,17 +222,22 @@
"0.76",
"0.76",
"0",
"3",
"0",
"0",
"0",
"0",
"0",
"9",
"0",
"0",
"15",
"0",
"0",
"3",
"0",
"0",
"3",
"0",
"0",
"0",
Expand All @@ -242,27 +247,22 @@
"0",
"0",
"0",
"0.01",
"0",
"0.01",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.0013",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0",
"0.004",
"0.0066",
"0.0013",
"0.0013",
"0"
]
}
Expand Down
Loading

0 comments on commit f906803

Please sign in to comment.