-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improved atVersion.supportedByAutomation
field handling
#1182
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
70d6945
First attempt at cache, failing tests
stalgiag 54fb645
Merge branch 'development' into improved-supported-by-automation-field
stalgiag 8916cb6
Simplification getAtVersionWithRequirements
stalgiag 5899149
Import resolver by property name in AtVersion resolver
stalgiag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const supportedByAutomation = require('./supportedByAutomationResolver'); | ||
|
||
const AtVersion = { | ||
supportedByAutomation | ||
}; | ||
|
||
module.exports = AtVersion; |
16 changes: 16 additions & 0 deletions
16
server/resolvers/AtVersion/supportedByAutomationResolver.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const { getAtVersionById } = require('../../models/services/AtService'); | ||
const { | ||
isSupportedByAutomation | ||
} = require('../../util/isSupportedByAutomation'); | ||
|
||
const supportedByAutomationResolver = async (parent, _, { transaction }) => { | ||
const atVersion = await getAtVersionById({ | ||
id: parent.id, | ||
transaction | ||
}); | ||
return isSupportedByAutomation(atVersion.at.id, atVersion.name, { | ||
transaction | ||
}); | ||
}; | ||
|
||
module.exports = supportedByAutomationResolver; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const AtLoader = require('../models/loaders/AtLoader'); | ||
const { AT_VERSIONS_SUPPORTED_BY_COLLECTION_JOBS } = require('./constants'); | ||
|
||
let atIdToNameCache = {}; | ||
|
||
const isSupportedByAutomation = async function ( | ||
atId, | ||
versionName, | ||
{ transaction } | ||
) { | ||
if (Object.keys(atIdToNameCache).length === 0) { | ||
const ats = await AtLoader().getAll({ transaction }); | ||
for (const at of ats) { | ||
atIdToNameCache[at.id] = at.name; | ||
} | ||
} | ||
const atName = atIdToNameCache[atId]; | ||
if (!atName) { | ||
console.warn( | ||
`Attempt to check if ${versionName} is supported by automation for unknown AT ${atId}` | ||
); | ||
return false; | ||
} | ||
const supportedVersions = | ||
AT_VERSIONS_SUPPORTED_BY_COLLECTION_JOBS[atName] || []; | ||
const isSupported = supportedVersions.includes(versionName); | ||
return isSupported; | ||
}; | ||
|
||
module.exports = { isSupportedByAutomation }; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To the best of my understanding, only one of these may exist at a time so conditionally checking may be good, with
exactAtVersion
being the priority. Does that change your thoughts on this comparison?I suppose it shouldn't matter though, since in the instance of the one (exact or minimum) that doesn't exist,
undefined === undefined
will be evaluated to true anyways anyways.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think it still makes sense because we are ensuring the Reports are a match and so if one has an
undefined
minimum then the other would as well. One or the other is going to be a useless check since having only a minimum or a required is probably enforced elsewhere but I think it is a lower cognitive load to read than doing anOR
between those two.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough on the cognitive load, this is fine with me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!