Skip to content

Commit 794c569

Browse files
authored
Additional checks for AtVersion automation run support (#1227)
* Explicit check for AtVersion automation run support in getAtVersionWithRequirements * revert server/resources/at.json change * Formatting
1 parent 94792cc commit 794c569

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

server/util/getAtVersionWithRequirements.js

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const { Op } = require('sequelize');
22
const { getAtVersions } = require('../models/services/AtService');
3+
const { AT_VERSIONS_SUPPORTED_BY_COLLECTION_JOBS } = require('./constants');
34

45
const getAtVersionWithRequirements = async (
56
atId,
@@ -33,11 +34,16 @@ const getAtVersionWithRequirements = async (
3334
transaction
3435
});
3536

36-
const latestSupportedAtVersion = matchingAtVersions.find(async atv => {
37-
// supportedByAutomation is a computed graphql field,
38-
// so we need to compute directly here
39-
return atv.supportedByAutomation;
40-
});
37+
const supportedVersions =
38+
AT_VERSIONS_SUPPORTED_BY_COLLECTION_JOBS[
39+
matchingAtVersions[0]?.at?.name
40+
] || [];
41+
42+
const latestSupportedAtVersion = matchingAtVersions.find(
43+
atv =>
44+
supportedVersions.includes(atv.name) &&
45+
new Date(atv.releasedAt) >= new Date(minimumAtVersion.releasedAt)
46+
);
4147

4248
if (!latestSupportedAtVersion) {
4349
throw new Error(

0 commit comments

Comments
 (0)