@@ -22,17 +22,21 @@ const {
2222 getMeshesWithParentIds,
2323 sharedIdsToExternalIds,
2424} = require ( './scenes' ) ;
25+ const { getLatestRevision, getRevisionByIdOrTag } = require ( '../../../../../models/revisions' ) ;
2526const { getMetadataByRules, getMetadataWithMatchingData } = require ( '../../../../../models/metadata' ) ;
2627const { idTypes, idTypesToKeys } = require ( '../../../../../models/metadata.constants' ) ;
27- const { getLatestRevision } = require ( '../../../../../models/revisions' ) ;
2828const { getNodesByIds } = require ( '../../../../../models/scenes' ) ;
2929const { stringToUUID } = require ( '../../../../../utils/helper/uuids' ) ;
3030
3131const TicketGroups = { } ;
3232
3333const getObjectArrayFromRules = async ( teamspace , project , model , revId , rules , returnMeshIds ) => {
3434 let revision = revId ;
35- if ( ! revision ) {
35+
36+ if ( revision ) {
37+ const rev = await getRevisionByIdOrTag ( teamspace , model , revision , { _id : 1 } ) ;
38+ revision = rev . _id ;
39+ } else {
3640 try {
3741 const rev = await getLatestRevision ( teamspace , model , { _id : 1 } ) ;
3842 revision = rev . _id ;
@@ -101,7 +105,7 @@ const convertToExternalIds = async (teamspace, project, containerEntries) => {
101105 if ( res ) {
102106 // eslint-disable-next-line no-underscore-dangle
103107 delete convertedObject . _ids ;
104- convertedObject [ res . type ] = res . values ;
108+ convertedObject [ res . key ] = res . values ;
105109 }
106110 return convertedObject ;
107111 } ) ) ;
@@ -118,7 +122,10 @@ const convertToMeshIds = async (teamspace, project, revId, containerEntry) => {
118122 const { container } = containerEntry ;
119123
120124 let revision = revId ;
121- if ( ! revision ) {
125+ if ( revision ) {
126+ const rev = await getRevisionByIdOrTag ( teamspace , container , revision , { _id : 1 } ) ;
127+ revision = rev . _id ;
128+ } else {
122129 try {
123130 const rev = await getLatestRevision ( teamspace , container , { _id : 1 } ) ;
124131 revision = rev . _id ;
@@ -132,6 +139,7 @@ const convertToMeshIds = async (teamspace, project, revId, containerEntry) => {
132139 const idType = getCommonElements ( Object . keys ( containerEntry ) , Object . keys ( idTypesToKeys ) ) [ 0 ] ;
133140 const metadata = await getMetadataWithMatchingData ( teamspace , container , revision ,
134141 idTypesToKeys [ idType ] , containerEntry [ idType ] , { parents : 1 } ) ;
142+
135143 const meshIds = await getMeshesWithParentIds ( teamspace , project , container , revision ,
136144 metadata . flatMap ( ( { parents } ) => parents ) ) ;
137145
0 commit comments