-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
123 changed files
with
2,418 additions
and
775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
/* eslint-disable max-len */ | ||
import db from 'api/utils/testing_db'; | ||
|
||
const entityId = db.id(); | ||
const entityIdEn = db.id(); | ||
const entityIdPt = db.id(); | ||
const sharedId = 'sharedId'; | ||
const toDeleteId = db.id(); | ||
const attachmentToEdit = db.id(); | ||
|
||
export default { | ||
entities: [ | ||
{_id: toDeleteId, attachments: [{filename: 'other.doc'}, {filename: 'toDelete.txt', originalname: 'common name 1.not'}]}, | ||
{_id: entityId, file: {originalname: 'source doc', filename: 'filename'}, attachments: [{_id: db.id(), originalname: 'o1', filename: 'other.doc'}, {_id: attachmentToEdit, filename: 'match.doc', originalname: 'common name 2.not'}]} | ||
{sharedId: toDeleteId.toString(), _id: toDeleteId, attachments: [{filename: 'other.doc'}, {filename: 'toDelete.txt', originalname: 'common name 1.not'}]}, | ||
{sharedId, _id: entityId, file: {originalname: 'source doc', filename: 'filename'}, attachments: [{_id: db.id(), originalname: 'o1', filename: 'other.doc'}, {_id: attachmentToEdit, filename: 'match.doc', originalname: 'common name 2.not'}]}, | ||
{sharedId, _id: entityIdEn, file: {originalname: 'source doc', filename: 'filenameEn'}, attachments: [{_id: db.id(), originalname: 'o1', filename: 'otherEn.doc'}]}, | ||
{sharedId, _id: entityIdPt, file: {originalname: 'source doc', filename: 'filenamePt'}} | ||
] | ||
}; | ||
|
||
export { | ||
entityId, | ||
entityIdEn, | ||
entityIdPt, | ||
sharedId, | ||
toDeleteId, | ||
attachmentToEdit | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import P from 'bluebird'; | ||
import entities from '../entities/entitiesModel'; | ||
import mongoose from 'mongoose'; | ||
|
||
import languages from '../../shared/languages'; | ||
|
||
entities.get({type: 'document'}, {_id: 1}) | ||
.then(documents => { | ||
return P.resolve(documents).map(({_id}) => { | ||
return entities.get({_id}) | ||
.then(([doc]) => { | ||
if (!doc.file || !doc.fullText) { | ||
return; | ||
} | ||
|
||
doc.file.fullText = doc.file.fullText || doc.fullText; | ||
doc.file.language = languages.detect(doc.file.fullText, 'franc'); | ||
delete doc.fullText; | ||
|
||
return entities.save(doc) | ||
.then(() => { | ||
console.log(doc.title + ' Migrated!'); | ||
}); | ||
}); | ||
}, {concurrency: 1}); | ||
}) | ||
.then(() => { | ||
entities.db.collection.update({}, | ||
{$unset: {fullText: true}}, | ||
{multi: true, safe: true}, | ||
(err) => { | ||
if (err) { | ||
throw err; | ||
} | ||
console.log('FullText deleted from collection\'s root!'); | ||
mongoose.disconnect(); | ||
} | ||
); | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
mongoose.disconnect(); | ||
}); |
Oops, something went wrong.