Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

survey-generator.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. const not_important = '120'
  2. const somewhat_important = '140'
  3. const important = '160'
  4. const very_important = '180'
  5. const extremely_important = '200'
  6. const mandatory = '400'
  7. // -
  8. // 1440 - 2400 total range
  9. // 1440 - 1900 limited range
  10. // -
  11. // Reserved for REALLY important answers
  12. // like full-time vs part-time
  13. // and remote vs onsite only
  14. // 400 mandatory
  15. const importance = [
  16. not_important,
  17. somewhat_important,
  18. important,
  19. very_important,
  20. extremely_important,
  21. ]
  22. const langs = [
  23. 'javascript',
  24. 'python',
  25. 'ruby',
  26. 'erlang',
  27. 'haskall',
  28. 'php',
  29. 'swift',
  30. 'rust',
  31. 'objective-c',
  32. 'common lisp',
  33. 'java',
  34. 'perl',
  35. 'cobol',
  36. 'fortran',
  37. 'julia',
  38. 'c#',
  39. 'go',
  40. 'c++',
  41. ]
  42. const duration = ['full', 'part']
  43. const location = ['onsite', 'remote', 'flexible']
  44. const otherWeightLookup = {
  45. full: mandatory,
  46. part: mandatory,
  47. onsite: mandatory,
  48. remote: mandatory,
  49. flexible: mandatory,
  50. }
  51. const rand = max => {
  52. return Math.floor(Math.random() * max) < 1
  53. ? 1
  54. : Math.floor(Math.random() * max)
  55. }
  56. class DummyProfile {
  57. constructor() {
  58. this.profileResponses = null
  59. this.langPref = null
  60. this.durationPref = null
  61. this.locationPref = null
  62. // profile is constructed of 12 answers, 2 for each dimension
  63. this.profileResponses = this.getRandomAnswers(12, importance)
  64. this.langPref = this.getRandomAnswers(rand(4), langs)
  65. this.durationPref = this.getRandomAnswers(1, duration)
  66. this.locationPref = this.getRandomAnswers(1, location)
  67. }
  68. getRandomAnswers(count, options) {
  69. const answers = []
  70. for (let i = 0; i < count; i++) {
  71. const random = rand(options.length)
  72. answers.push(options[random])
  73. }
  74. return answers
  75. }
  76. }
  77. const generateDummyProfiles = count => {
  78. const profiles = []
  79. for (let i = 0; i < count; i++) {
  80. const dummyProfile = new DummyProfile()
  81. profiles.push(dummyProfile)
  82. }
  83. profiles.forEach(dummy => {
  84. dummy.profileResponses = dummy.profileResponses.map(answer => {
  85. const answerObj = {}
  86. const random = rand(12)
  87. answerObj[random] = answer
  88. return answerObj
  89. })
  90. })
  91. return profiles
  92. }
  93. const generatedSeekers = generateDummyProfiles(100)
  94. const generatedProviders = generateDummyProfiles(10)
  95. const compareProfiles = (profile, unorderedPotentialMatches) => {
  96. const scored = unorderedPotentialMatches.map(potentialMatch => {
  97. // score the match
  98. const score = rand(1900)
  99. // add the match to object keyed by score
  100. return { score, profile: potentialMatch }
  101. })
  102. // create array ordered by score
  103. const orderedPotentialMatches = scored.sort((a, b) => a.score - b.score)
  104. return orderedPotentialMatches
  105. }
  106. generatedSeekers.forEach(seeker => {
  107. console.log(compareProfiles(seeker, generatedProviders))
  108. })
  109. // console.log(generatedProviders)
  110. // console.log(generatedSeekers[0].profileResponses)
  111. // console.log(generatedProviders[0].profileResponses)