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 4d4232a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
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 4d4232a

Please sign in to comment.