Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
chore: merge latest master
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelKohler committed Aug 14, 2019
2 parents 64a48e5 + 49906de commit fb2264c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
12 changes: 8 additions & 4 deletions scripts/exporter.js
Expand Up @@ -90,10 +90,14 @@ function getValidatedSentences(languageCode, sentences) {
}

function dedupeSentences(languageCode, sentences, path) {
const alreadyExistingSentences = getCVSentencesFor(languageCode, path);
const nonDupes = sentences.filter((sentence) => !alreadyExistingSentences.includes(sentence));
console.log(` - Got ${nonDupes.length} sentences not already existing in CV..`);
return nonDupes;
const alreadyExistingCVSentences = getCVSentencesFor(languageCode, path);
const dedupedSentences = Array.from(new Set(sentences));
const numberOfDupes = sentences.length - dedupedSentences.length;
console.log(` - Got ${numberOfDupes} duplicated sentences in Sentence Collector..`);

const notAlreadyExistingInCV = dedupedSentences.filter((sentence) => !alreadyExistingCVSentences.includes(sentence));
console.log(` - Got ${notAlreadyExistingInCV.length} sentences not already existing in CV..`);
return notAlreadyExistingInCV;
}

function getCVSentencesFor(languageCode, path) {
Expand Down
5 changes: 4 additions & 1 deletion shared/db/collections/sentences-meta.js
Expand Up @@ -398,7 +398,10 @@ export default class SentencesMeta {
const filters = {};
filters.approved = true;

return this.getAllPaginated(language, filters);
const allRecords = await this.getAllPaginated(language, filters);
const approvedRecords = allRecords.filter((record) => this.checkIfApproved(record));

return approvedRecords;
}

prepareForSubmission(sentences) {
Expand Down

0 comments on commit fb2264c

Please sign in to comment.