26 lines
701 B
JavaScript
Raw Normal View History

2021-03-02 17:09:35 +01:00
'use strict';
const { pick, prop, intersection } = require('lodash/fp');
2021-03-11 10:41:35 +01:00
const shouldBeProcessed = processedLocaleCodes => entry => {
2021-03-02 17:09:35 +01:00
return (
2021-03-11 10:41:35 +01:00
entry.localizations.length > 0 &&
2021-03-02 17:09:35 +01:00
intersection(entry.localizations.map(prop('locale')), processedLocaleCodes).length === 0
);
};
2021-03-11 10:41:35 +01:00
const getUpdatesInfo = ({ entriesToProcess, attributesToMigrate }) => {
2021-03-02 17:09:35 +01:00
const updates = [];
for (const entry of entriesToProcess) {
const attributesValues = pick(attributesToMigrate, entry);
2021-03-11 10:41:35 +01:00
const entriesIdsToUpdate = entry.localizations.map(prop('id'));
2021-03-02 17:09:35 +01:00
updates.push({ entriesIdsToUpdate, attributesValues });
}
return updates;
};
module.exports = {
2021-03-11 10:41:35 +01:00
shouldBeProcessed,
2021-03-02 17:09:35 +01:00
getUpdatesInfo,
};