From 794c569741c04b2b63c12fdc1b022377d8de248b Mon Sep 17 00:00:00 2001 From: Howard Edwards Date: Wed, 2 Oct 2024 13:42:58 -0400 Subject: [PATCH] Additional checks for AtVersion automation run support (#1227) * Explicit check for AtVersion automation run support in getAtVersionWithRequirements * revert server/resources/at.json change * Formatting --- server/util/getAtVersionWithRequirements.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/server/util/getAtVersionWithRequirements.js b/server/util/getAtVersionWithRequirements.js index eb72940d2..0af679f31 100644 --- a/server/util/getAtVersionWithRequirements.js +++ b/server/util/getAtVersionWithRequirements.js @@ -1,5 +1,6 @@ const { Op } = require('sequelize'); const { getAtVersions } = require('../models/services/AtService'); +const { AT_VERSIONS_SUPPORTED_BY_COLLECTION_JOBS } = require('./constants'); const getAtVersionWithRequirements = async ( atId, @@ -33,11 +34,16 @@ const getAtVersionWithRequirements = async ( transaction }); - const latestSupportedAtVersion = matchingAtVersions.find(async atv => { - // supportedByAutomation is a computed graphql field, - // so we need to compute directly here - return atv.supportedByAutomation; - }); + const supportedVersions = + AT_VERSIONS_SUPPORTED_BY_COLLECTION_JOBS[ + matchingAtVersions[0]?.at?.name + ] || []; + + const latestSupportedAtVersion = matchingAtVersions.find( + atv => + supportedVersions.includes(atv.name) && + new Date(atv.releasedAt) >= new Date(minimumAtVersion.releasedAt) + ); if (!latestSupportedAtVersion) { throw new Error(