Skip to content

Commit

Permalink
ISSUE #4641 Should be able to reference revisions by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
carmenfan committed Jan 15, 2024
1 parent 4473643 commit 1f8fa06
Showing 1 changed file with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ const {
getMeshesWithParentIds,
sharedIdsToExternalIds,
} = require('./scenes');
const { getLatestRevision, getRevisionByIdOrTag } = require('../../../../../models/revisions');
const { getMetadataByRules, getMetadataWithMatchingData } = require('../../../../../models/metadata');
const { idTypes, idTypesToKeys } = require('../../../../../models/metadata.constants');
const { getLatestRevision } = require('../../../../../models/revisions');
const { getNodesByIds } = require('../../../../../models/scenes');
const { stringToUUID } = require('../../../../../utils/helper/uuids');

const TicketGroups = {};

const getObjectArrayFromRules = async (teamspace, project, model, revId, rules, returnMeshIds) => {
let revision = revId;
if (!revision) {

if (revision) {
const rev = await getRevisionByIdOrTag(teamspace, model, revision, { _id: 1 });
revision = rev._id;
} else {
try {
const rev = await getLatestRevision(teamspace, model, { _id: 1 });
revision = rev._id;
Expand Down Expand Up @@ -101,7 +105,7 @@ const convertToExternalIds = async (teamspace, project, containerEntries) => {
if (res) {
// eslint-disable-next-line no-underscore-dangle
delete convertedObject._ids;
convertedObject[res.type] = res.values;
convertedObject[res.key] = res.values;
}
return convertedObject;
}));
Expand All @@ -118,7 +122,10 @@ const convertToMeshIds = async (teamspace, project, revId, containerEntry) => {
const { container } = containerEntry;

let revision = revId;
if (!revision) {
if (revision) {
const rev = await getRevisionByIdOrTag(teamspace, container, revision, { _id: 1 });
revision = rev._id;
} else {
try {
const rev = await getLatestRevision(teamspace, container, { _id: 1 });
revision = rev._id;
Expand All @@ -132,6 +139,7 @@ const convertToMeshIds = async (teamspace, project, revId, containerEntry) => {
const idType = getCommonElements(Object.keys(containerEntry), Object.keys(idTypesToKeys))[0];
const metadata = await getMetadataWithMatchingData(teamspace, container, revision,
idTypesToKeys[idType], containerEntry[idType], { parents: 1 });

const meshIds = await getMeshesWithParentIds(teamspace, project, container, revision,
metadata.flatMap(({ parents }) => parents));

Expand Down

0 comments on commit 1f8fa06

Please sign in to comment.