Skip to content

Commit

Permalink
add Polish data
Browse files Browse the repository at this point in the history
  • Loading branch information
mikolajkalwa committed Aug 7, 2022
1 parent ac8e874 commit d2ed3c9
Show file tree
Hide file tree
Showing 10 changed files with 3,068 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/.nextRelease/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,7 @@ class Generator {
NL: "Netherlands",
NO: "Norway",
NZ: "New Zealand",
PL: "Poland",
RS: "Serbia",
TR: "Turkey",
UA: "Ukraine",
Expand Down
44 changes: 44 additions & 0 deletions api/.nextRelease/data/PL/inject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { transliterate } = require('transliteration');
const { random, include, pad, randomItem } = require('../../api');

module.exports = (inc, contents, datasets) => {
const lastName = contents.gender === 'male' ? randomItem(datasets['PL'].male_last) : randomItem(datasets['PL'].female_last);

include(inc, contents, 'phone', `+48 ${random(3, 3)} ${random(3, 3)} ${random(3, 3)}`);

include(inc, contents, 'cell', `+48 ${random(3, 3)} ${random(3, 3)} ${random(3, 3)}`);

include(inc, contents, 'id', () => {
const dobDate = new Date(contents.dob.date);
const generatePesel = () => {
const pesel = `${dobDate.getFullYear().toString().slice(-2)
}${pad(dobDate.getMonth() + 1, 2)
}${pad(dobDate.getDate(), 2)
}${random(3, 3)
}${contents.gender === 'male' ? randomItem([1, 3, 5, 7, 9]) : randomItem([0, 2, 4, 6, 8]) // odd number for man, even number for woman
}`
const checksum = 10 - ((pesel[0] * 1 + pesel[1] * 3 + pesel[2] * 7 + pesel[3] * 9 + pesel[4] * 1 + pesel[5] * 3 +
pesel[6] * 7 + pesel[7] * 9 + pesel[8] * 1 + pesel[9] * 3) % 10) % 10;

return `${pesel}${checksum}`;
};
contents.id = {
name: 'PESEL',
value: generatePesel()
}
});

include(inc, contents, 'location', () => {
contents.location.postcode = `${random(3, 2)}-${random(3, 3)}`;
});

include(inc, contents, 'name', () => {
contents.name.title = contents.gender === 'male' ? 'Pan' : 'Pani';
contents.name.last = lastName;
});

include(inc, contents, 'email', () => {
contents.email = transliterate(`${contents.name.first}.${lastName}`).replace(/ /g, '').toLowerCase() + '@example.com'
});

};
Loading

0 comments on commit d2ed3c9

Please sign in to comment.