mirror of
https://github.com/strapi/strapi.git
synced 2025-07-27 19:10:01 +00:00
28 lines
775 B
JavaScript
28 lines
775 B
JavaScript
'use strict';
|
|
|
|
const { pick, prop, intersection } = require('lodash/fp');
|
|
|
|
const shouldBeProcesseed = processedLocaleCodes => entry => {
|
|
return (
|
|
entry.localizations.length > 1 &&
|
|
intersection(entry.localizations.map(prop('locale')), processedLocaleCodes).length === 0
|
|
);
|
|
};
|
|
|
|
const getUpdatesInfo = ({ entriesToProcess, locale, attributesToMigrate }) => {
|
|
const updates = [];
|
|
for (const entry of entriesToProcess) {
|
|
const attributesValues = pick(attributesToMigrate, entry);
|
|
const entriesIdsToUpdate = entry.localizations
|
|
.filter(related => related.locale !== locale.code)
|
|
.map(prop('id'));
|
|
updates.push({ entriesIdsToUpdate, attributesValues });
|
|
}
|
|
return updates;
|
|
};
|
|
|
|
module.exports = {
|
|
shouldBeProcesseed,
|
|
getUpdatesInfo,
|
|
};
|