Skip to content

Commit

Permalink
Merge pull request #373 from sharad23/task/MIG-105
Browse files Browse the repository at this point in the history
MIG-105: Removed the work around function
  • Loading branch information
nahueld authored May 17, 2022
2 parents 986b019 + 7d091b1 commit e0fe0bc
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 68 deletions.
54 changes: 0 additions & 54 deletions packages/mdctl-axon-tools/__tests__/MIG-63/MIG-63.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const MenuConfigMap = require('../../lib/mappings/maps/MenuConfigMap')
const ReviewsTypesMap = require('../../lib/mappings/maps/ReviewTypesMap')
const MenuConfigMapping = require('../../lib/mappings/MenuConfigMapping')

describe('MenuConfigMappings', () => {

Expand Down Expand Up @@ -163,59 +162,6 @@ describe('MenuConfigMappings', () => {
])
})

it('getMappingScript', async() => {
const menuConfigMapping = new MenuConfigMapping(org),
script = await menuConfigMapping.getMappingScript(),

expectedScript = `
const { run } = require('expressions')
const mappings = [{"path":"c_study.aaa.c_menu_config.bbb.c_group_id","mapTo":{"$pathTo":[{"$dbNext":{"object":"c_group","operation":"cursor","paths":["_id"],"where":{"c_key":"ccc"}}},"_id"]}},{"path":"c_study.aaa.c_review_types.bbb.c_roles","mapTo":{"$dbNext":{"expressionPipeline":[{"$transform":{"each":{"in":{"$map":{"as":"role","in":{"$pathTo":["$$role","_id"]},"input":{"$filter":{"as":"role","cond":{"$in":["$$role.code",{"$array":[{"$literal":"admin"}]}]},"input":"$$ROOT.roles"}}}}}}}],"maxTimeMS":10000,"object":"org","operation":"cursor","paths":["roles"]}}},{"path":"c_group_task.ppp.c_required_reviews","mapTo":{"$dbNext":{"expressionPipeline":[{"$transform":{"each":{"in":{"$map":{"as":"reviewType","in":"$$reviewType._id","input":{"$filter":{"as":"reviewType","cond":{"$in":["$$reviewType.c_key",{"$array":[{"$literal":"bbb"}]}]},"input":"$$ROOT.c_review_types"}}}}}}}],"maxTimeMS":10000,"object":"c_study","operation":"cursor"}}}]
mappings.forEach(({ path, mapTo }) => {
const [entity, entityKey, property, ...rest] = path.split('.'),
isDocPropUpdate = !!rest.length,
value = run(mapTo)
if (isDocPropUpdate) {
const [entityResult] = org.objects[entity]
.find({ c_key: entityKey })
.paths(property)
.limit(1)
.toArray()
if (!entityResult) return
const documentProps = entityResult[property]
if (!documentProps) return
const [docPropKey, docProp] = rest
if (!docPropKey || !docProp) return
const propToUpdate = documentProps.find(({ c_key }) => c_key === docPropKey),
idToUpdate = propToUpdate._id
return org.objects[entity]
.updateOne({ c_key: entityKey })
.pathUpdate(property + '/' + idToUpdate + '/' + docProp , value)
}
//normal prop update
return org.objects[entity]
.updateOne({ c_key: entityKey }, { $set: { [property]: value }})
.execute()
})`

expect(script)
.toBe(expectedScript)
})

describe('MIG-9: Review types mapping', () => {

it('getStudyReviewMaps', async() => {
Expand Down
14 changes: 0 additions & 14 deletions packages/mdctl-axon-tools/lib/mappings/MenuConfigMapping.js

This file was deleted.

0 comments on commit e0fe0bc

Please sign in to comment.