Skip to content

Commit

Permalink
use unique language keys on migration (#6237)
Browse files Browse the repository at this point in the history
  • Loading branch information
daneryl authored Nov 6, 2023
1 parent 50141a3 commit 7fdf780
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ export default {

async up(db) {
const settings = await db.collection('settings').findOne();
const languages = settings.languages.map(l => l.key);
const languages = settings.languages
.map(l => l.key)
.filter((value, index, array) => array.indexOf(value) === index);

await db.collection('translationsV2').deleteMany({
key: { $in: deletedKeys.concat(newKeys).map(k => k.key) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe('migration update translations of settings new Users/Groups UI', () =>
.find({ key: { $in: newKeys.map(k => k.key) } })
.toArray();

expect(translations.length).toBe(newKeys.length * fixtures.settings[0].languages.length);
expect(translations.length).toBe(26);
});

it('should be idempotent (do not throw an error on multiple runs)', async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import db from 'api/utils/testing_db';

const fixturesDB = {
settings: [{ _id: db.id(), languages: [{ key: 'en' }, { key: 'es' }] }],
settings: [{ _id: db.id(), languages: [{ key: 'en' }, { key: 'es' }, { key: 'es' }] }],
translationsV2: [
{
_id: db.id(),
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwazi",
"version": "1.141.1",
"version": "1.141.2",
"description": "Uwazi is a free, open-source solution for organising, analysing and publishing your documents.",
"keywords": [
"react"
Expand Down

0 comments on commit 7fdf780

Please sign in to comment.