@@ -22,17 +22,21 @@ const {
22
22
getMeshesWithParentIds,
23
23
sharedIdsToExternalIds,
24
24
} = require ( './scenes' ) ;
25
+ const { getLatestRevision, getRevisionByIdOrTag } = require ( '../../../../../models/revisions' ) ;
25
26
const { getMetadataByRules, getMetadataWithMatchingData } = require ( '../../../../../models/metadata' ) ;
26
27
const { idTypes, idTypesToKeys } = require ( '../../../../../models/metadata.constants' ) ;
27
- const { getLatestRevision } = require ( '../../../../../models/revisions' ) ;
28
28
const { getNodesByIds } = require ( '../../../../../models/scenes' ) ;
29
29
const { stringToUUID } = require ( '../../../../../utils/helper/uuids' ) ;
30
30
31
31
const TicketGroups = { } ;
32
32
33
33
const getObjectArrayFromRules = async ( teamspace , project , model , revId , rules , returnMeshIds ) => {
34
34
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 {
36
40
try {
37
41
const rev = await getLatestRevision ( teamspace , model , { _id : 1 } ) ;
38
42
revision = rev . _id ;
@@ -101,7 +105,7 @@ const convertToExternalIds = async (teamspace, project, containerEntries) => {
101
105
if ( res ) {
102
106
// eslint-disable-next-line no-underscore-dangle
103
107
delete convertedObject . _ids ;
104
- convertedObject [ res . type ] = res . values ;
108
+ convertedObject [ res . key ] = res . values ;
105
109
}
106
110
return convertedObject ;
107
111
} ) ) ;
@@ -118,7 +122,10 @@ const convertToMeshIds = async (teamspace, project, revId, containerEntry) => {
118
122
const { container } = containerEntry ;
119
123
120
124
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 {
122
129
try {
123
130
const rev = await getLatestRevision ( teamspace , container , { _id : 1 } ) ;
124
131
revision = rev . _id ;
@@ -132,6 +139,7 @@ const convertToMeshIds = async (teamspace, project, revId, containerEntry) => {
132
139
const idType = getCommonElements ( Object . keys ( containerEntry ) , Object . keys ( idTypesToKeys ) ) [ 0 ] ;
133
140
const metadata = await getMetadataWithMatchingData ( teamspace , container , revision ,
134
141
idTypesToKeys [ idType ] , containerEntry [ idType ] , { parents : 1 } ) ;
142
+
135
143
const meshIds = await getMeshesWithParentIds ( teamspace , project , container , revision ,
136
144
metadata . flatMap ( ( { parents } ) => parents ) ) ;
137
145
0 commit comments