Skip to content
This repository has been archived by the owner on Jul 25, 2018. It is now read-only.

Commit

Permalink
Merge pull request #336 from sw360/dev/migrationeccmoderation
Browse files Browse the repository at this point in the history
fix(migration): improving ECC coverage of moderation requests
review-by:[email protected]
tested-by:[email protected],[email protected]
  • Loading branch information
mcjaeger authored Feb 15, 2017
2 parents 9639464 + b2b852a commit e14d95c
Showing 1 changed file with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,58 @@
if changed:
db.save(release)

print 'Done'
print 'Done with releases.'

# --------------------------------

print 'Moving moderation release additions ecc fields to eccInformation'

moderations_with_release_additions_fun = '''function(doc){
if (doc.type=="moderation" && doc.releaseAdditions && doc.releaseAdditions.clearingInformation){
emit(doc._id, doc)
}
}'''

moderations_with_release_additions = db.query(moderations_with_release_additions_fun)

for moderation_row in moderations_with_release_additions:
moderation = moderation_row.value
release_additions = moderation['releaseAdditions']
release_additions[ECC_INFORMATION] = {}
changed = False
for field in ['AL', 'ECCN', 'assessorContactPerson', 'assessorDepartment', 'assessmentDate', 'eccComment', 'eccStatus', 'materialIndexNumber']:
if field in release_additions[CLEARING_INFORMATION]:
release_additions[ECC_INFORMATION][field] = release_additions[CLEARING_INFORMATION][field]
del release_additions[CLEARING_INFORMATION][field]
changed = True
if changed:
db.save(moderation)

print 'Done with moderation release addition.'

# --------------------------------

print 'Moving moderation release deletions ecc fields to eccInformation'

moderations_with_release_deletions_fun = '''function(doc){
if (doc.type=="moderation" && doc.releaseDeletions && doc.releaseDeletions.clearingInformation){
emit(doc._id, doc)
}
}'''

moderations_with_release_deletions = db.query(moderations_with_release_deletions_fun)

for moderation_row in moderations_with_release_deletions:
moderation = moderation_row.value
release_deletions = moderation['releaseDeletions']
release_deletions[ECC_INFORMATION] = {}
changed = False
for field in ['AL', 'ECCN', 'assessorContactPerson', 'assessorDepartment', 'assessmentDate', 'eccComment', 'eccStatus', 'materialIndexNumber']:
if field in release_deletions[CLEARING_INFORMATION]:
release_deletions[ECC_INFORMATION][field] = release_deletions[CLEARING_INFORMATION][field]
del release_deletions[CLEARING_INFORMATION][field]
changed = True
if changed:
db.save(moderation)

print 'Done with moderation release deletions.'

0 comments on commit e14d95c

Please sign in to comment.