Skip to content

Commit

Permalink
SOF-6631: avoid toJSON, simplify filters
Browse files Browse the repository at this point in the history
  • Loading branch information
pranabdas committed Aug 16, 2023
1 parent a43e150 commit 018bda5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@exabyte-io/code.js": "2023.8.10-0",
"@exabyte-io/eslint-config": "^2022.11.17-0",
"@exabyte-io/made.js": "2022.6.15-0",
"@exabyte-io/application-flavors.js": "git+https://github.com/Exabyte-io/application-flavors#e1f10e79132659584dedc1bc37f9ce8969da075a",
"@exabyte-io/application-flavors.js": "git+https://github.com/Exabyte-io/application-flavors#de2c98f03a68ba740c26c5e4e0ffb1ca639c2deb",
"chai": "^4.3.4",
"eslint": "7.32.0",
"eslint-config-airbnb": "19.0.2",
Expand Down
24 changes: 12 additions & 12 deletions src/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,18 @@ export class Application extends NamedDefaultableInMemoryEntity {

get executables() {
const tree = getAppTree(this.prop("name"));
const executableList = Object.keys(tree).map((key) => {
return new this.constructor.Executable({ ...tree[key], name: key });
});
const allowedExecutables = executableList.filter((exe) => {
const { supportedApplicationVersions } = exe.toJSON();
return (
!supportedApplicationVersions ||
(supportedApplicationVersions &&
supportedApplicationVersions.includes(this.prop("version")))
);
});
return allowedExecutables;
return Object.keys(tree)
.filter((key) => {
const { supportedApplicationVersions } = tree[key];
return (
!supportedApplicationVersions ||
(supportedApplicationVersions &&
supportedApplicationVersions.includes(this.prop("version")))
);
})
.map((key) => {
return new this.constructor.Executable({ ...tree[key], name: key });
});
}

get hasAdvancedComputeOptions() {
Expand Down
4 changes: 2 additions & 2 deletions src/executable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ export class Executable extends mix(NamedDefaultableInMemoryEntity).with(Runtime
return config ? this.getFlavorByName(config.name) : this.defaultFlavor;
}

getFlavorByApplicationVersion(version) {
getFlavorsByApplicationVersion(version) {
const filteredFlavors = this.flavors.filter((flavor) => {
const { supportedApplicationVersions } = flavor.toJSON();
const supportedApplicationVersions = flavor.prop("supportedApplicationVersions");
return (
!supportedApplicationVersions ||
(supportedApplicationVersions && supportedApplicationVersions.includes(version))
Expand Down

0 comments on commit 018bda5

Please sign in to comment.