Removed invalid and duplicate email validations in members importer

This commit is contained in:
Nazar Gargol 2020-07-09 17:55:40 +12:00
parent 3086ac1439
commit bcfc3792cd
2 changed files with 4 additions and 34 deletions

View File

@ -61,14 +61,7 @@ export default Service.extend({
}));
} else {
// check can be done on whole set as it won't be too slow
const {invalidCount, emptyCount, duplicateCount} = this._checkEmails(data, mapping);
if (invalidCount) {
// @TODO: Remove error from displayed errors
validationErrors.push(new MemberImportError({
message: `Invalid email address (${formatNumber(invalidCount)})`,
type: 'warning'
}));
}
const {emptyCount} = this._checkEmails(data, mapping);
if (emptyCount) {
validationErrors.push(new MemberImportError({
@ -76,14 +69,6 @@ export default Service.extend({
type: 'warning'
}));
}
if (duplicateCount) {
// @TODO: Remove error from displayed errors
validationErrors.push(new MemberImportError({
message: `Duplicate email address (${formatNumber(duplicateCount)})`,
type: 'warning'
}));
}
}
return {validationErrors, mapping};
@ -184,29 +169,15 @@ export default Service.extend({
_checkEmails(validatedSet, mapping) {
let emptyCount = 0;
let invalidCount = 0;
let duplicateCount = 0;
let emailMap = {};
validatedSet.forEach((member) => {
let emailValue = member[mapping.email];
if (!emailValue) {
emptyCount += 1;
}
if (emailValue && !validator.isEmail(emailValue)) {
invalidCount += 1;
} else if (emailValue) {
if (emailMap[emailValue]) {
emailMap[emailValue] += 1;
duplicateCount += 1;
} else {
emailMap[emailValue] = 1;
}
}
});
return {invalidCount, emptyCount, duplicateCount};
return {emptyCount};
},
_countStripeRecors(validatedSet, mapping) {

View File

@ -77,7 +77,7 @@ describe('Integration: Service: member-import-validator', function () {
expect(validationErrors[0].message).to.equal('No email addresses found in the uploaded CSV.');
});
it('returns validation error for invalid email', async function () {
it('ignores validation for invalid email', async function () {
this.owner.register('service:membersUtils', Service.extend({
isStripeEnabled: false
}));
@ -90,8 +90,7 @@ describe('Integration: Service: member-import-validator', function () {
email: 'email@example.com'
}]);
expect(validationErrors.length).to.equal(1);
expect(validationErrors[0].message).to.equal('Invalid email address (1)');
expect(validationErrors.length).to.equal(0);
});
describe('data sampling method', function () {