Skip to content
This repository was archived by the owner on Dec 7, 2021. It is now read-only.

Commit 74a5a81

Browse files
committed
Inverting if statement
1 parent bfce1ec commit 74a5a81

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

src/providers/export/testAssetsSplitHelper.ts

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,25 @@ import { IAssetMetadata, ITag } from "../../models/applicationState";
66
* @param params Params containing substitution values
77
*/
88
export function splitTestAsset(allAssets: IAssetMetadata[], tags: ITag[], testSplitRatio: number): string[] {
9-
const testAssets: string[] = [];
9+
if (testSplitRatio <= 0 || testSplitRatio > 1) { return []; }
1010

11-
if (testSplitRatio > 0 && testSplitRatio <= 1) {
12-
const tagsAssetDict: { [index: string]: { assetList: Set<string> } } = {};
13-
tags.forEach((tag) => tagsAssetDict[tag.name] = { assetList: new Set() });
14-
allAssets.forEach((assetMetadata) => {
15-
assetMetadata.regions.forEach((region) => {
16-
region.tags.forEach((tagName) => {
17-
if (tagsAssetDict[tagName]) {
18-
tagsAssetDict[tagName].assetList.add(assetMetadata.asset.name);
19-
}
20-
});
11+
const testAssets: string[] = [];
12+
const tagsAssetDict: { [index: string]: { assetList: Set<string> } } = {};
13+
tags.forEach((tag) => tagsAssetDict[tag.name] = { assetList: new Set() });
14+
allAssets.forEach((assetMetadata) => {
15+
assetMetadata.regions.forEach((region) => {
16+
region.tags.forEach((tagName) => {
17+
if (tagsAssetDict[tagName]) {
18+
tagsAssetDict[tagName].assetList.add(assetMetadata.asset.name);
19+
}
2120
});
2221
});
22+
});
2323

24-
for (const tagKey of Object.keys(tagsAssetDict)) {
25-
const assetList = tagsAssetDict[tagKey].assetList;
26-
const testCount = Math.ceil(assetList.size * testSplitRatio);
27-
testAssets.push(...Array.from(assetList).slice(0, testCount));
28-
}
24+
for (const tagKey of Object.keys(tagsAssetDict)) {
25+
const assetList = tagsAssetDict[tagKey].assetList;
26+
const testCount = Math.ceil(assetList.size * testSplitRatio);
27+
testAssets.push(...Array.from(assetList).slice(0, testCount));
2928
}
3029
return testAssets;
3130
}

0 commit comments

Comments
 (0)