8000 MIG-105: Removed the work around function by sharad23 · Pull Request #373 · Medable/mdctl · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

MIG-105: Removed the work around function #373

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? 8000 Sign in to your account

Merged
merged 3 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()

B43C 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