| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- const not_important = '120'
- const somewhat_important = '140'
- const important = '160'
- const very_important = '180'
- const extremely_important = '200'
- const mandatory = '400'
- // -
- // 1440 - 2400 total range
- // 1440 - 1900 limited range
- // -
- // Reserved for REALLY important answers
- // like full-time vs part-time
- // and remote vs onsite only
- // 400 mandatory
-
- const importance = [
- not_important,
- somewhat_important,
- important,
- very_important,
- extremely_important,
- ]
-
- const langs = [
- 'javascript',
- 'python',
- 'ruby',
- 'erlang',
- 'haskall',
- 'php',
- 'swift',
- 'rust',
- 'objective-c',
- 'common lisp',
- 'java',
- 'perl',
- 'cobol',
- 'fortran',
- 'julia',
- 'c#',
- 'go',
- 'c++',
- ]
- const duration = ['full', 'part']
- const location = ['onsite', 'remote', 'flexible']
-
- const otherWeightLookup = {
- full: mandatory,
- part: mandatory,
- onsite: mandatory,
- remote: mandatory,
- flexible: mandatory,
- }
- const rand = max => {
- return Math.floor(Math.random() * max) < 1
- ? 1
- : Math.floor(Math.random() * max)
- }
-
- class DummyProfile {
- constructor() {
- this.profileResponses = null
- this.langPref = null
- this.durationPref = null
- this.locationPref = null
-
- // profile is constructed of 12 answers, 2 for each dimension
- this.profileResponses = this.getRandomAnswers(12, importance)
- this.langPref = this.getRandomAnswers(rand(4), langs)
- this.durationPref = this.getRandomAnswers(1, duration)
- this.locationPref = this.getRandomAnswers(1, location)
- }
- getRandomAnswers(count, options) {
- const answers = []
- for (let i = 0; i < count; i++) {
- const random = rand(options.length)
- answers.push(options[random])
- }
- return answers
- }
- }
-
- const generateDummyProfiles = count => {
- const profiles = []
- for (let i = 0; i < count; i++) {
- const dummyProfile = new DummyProfile()
- profiles.push(dummyProfile)
- }
- profiles.forEach(dummy => {
- dummy.profileResponses = dummy.profileResponses.map(answer => {
- const answerObj = {}
- const random = rand(12)
- answerObj[random] = answer
- return answerObj
- })
- })
- return profiles
- }
-
- const generatedSeekers = generateDummyProfiles(100)
- const generatedProviders = generateDummyProfiles(10)
-
- const compareProfiles = (profile, unorderedPotentialMatches) => {
- const scored = unorderedPotentialMatches.map(potentialMatch => {
- // score the match
- const score = rand(1900)
- // add the match to object keyed by score
- return { score, profile: potentialMatch }
- })
- // create array ordered by score
- const orderedPotentialMatches = scored.sort((a, b) => a.score - b.score)
- return orderedPotentialMatches
- }
-
- generatedSeekers.forEach(seeker => {
- console.log(compareProfiles(seeker, generatedProviders))
- })
- // console.log(generatedProviders)
- // console.log(generatedSeekers[0].profileResponses)
- // console.log(generatedProviders[0].profileResponses)
|