Skip to content

Commit

Permalink
Merge pull request #69 from keboola/COM-1327-ondra
Browse files Browse the repository at this point in the history
Skip disabled queries
  • Loading branch information
ondrajodas authored Feb 4, 2022
2 parents 55e67b9 + 7ca6f62 commit 86ecd78
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Configuration/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ public function getOutputBucket(): string
public function getQueries(string $configDefinition): array
{
if ($configDefinition === OldConfigDefinition::class) {
return $this->getValue(['parameters', 'queries'], []);
$queries = $this->getValue(['parameters', 'queries'], []);
return array_filter($queries, function ($query) {
return $query['enabled'];
});
} else {
return [$this->getValue(['parameters'], [])];
}
Expand Down
4 changes: 4 additions & 0 deletions tests/Keboola/GoogleAnalyticsExtractor/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public function testAppRun(string $configSuffix): void
$users = $this->getOutputFiles('users');
$usersManifests = $this->getManifestFiles('users');

$disabledUsers = $this->getOutputFiles('disabledUsers');

$manifests = $this->getManifestFiles('');

Assert::assertEquals(1, count($profiles));
Expand All @@ -73,6 +75,8 @@ public function testAppRun(string $configSuffix): void
Assert::assertEquals(1, count($users));
Assert::assertEquals(1, count($usersManifests));

Assert::assertEquals(0, count($disabledUsers));

foreach ($manifests as $manifestFile) {
$manifest = json_decode((string) file_get_contents((string) $manifestFile), true);
Assert::assertArrayHasKey('incremental', $manifest);
Expand Down
38 changes: 38 additions & 0 deletions tests/data/config_old.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,44 @@
}
]
}
},
{
"outputTable": "disabledUsers",
"enabled": false,
"query": {
"metrics": [
{
"expression": "ga:users"
},
{
"expression": "ga:pageviews"
},
{
"expression": "ga:bounces"
}
],
"dimensions": [
{
"name": "ga:date"
},
{
"name": "ga:source"
},
{
"name": "ga:medium"
},
{
"name": "ga:country"
}
],
"filtersExpression": "",
"dateRanges": [
{
"startDate": "-3 months",
"endDate": "-1 day"
}
]
}
}
]
}
Expand Down

0 comments on commit 86ecd78

Please sign in to comment.