Skip to content

Commit

Permalink
Additional checks for AtVersion automation run support (#1227)
Browse files Browse the repository at this point in the history
* Explicit check for AtVersion automation run support in getAtVersionWithRequirements

* revert server/resources/at.json change

* Formatting
  • Loading branch information
howard-e authored Oct 2, 2024
1 parent 94792cc commit 794c569
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions server/util/getAtVersionWithRequirements.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 794c569

Please sign in to comment.