Просмотр исходного кода

:sparkles: sketching out our backend match making architecture

master
j 5 лет назад
Родитель
Сommit
b2da121bba
1 измененных файлов: 51 добавлений и 0 удалений
  1. 51
    0
      backend/lib/services/match-maker.js

+ 51
- 0
backend/lib/services/match-maker.js Просмотреть файл

1
+class ScoreKeeper {
2
+    constructor() {}
3
+    score(proposer) {
4
+        return { ...proposer }
5
+    }
6
+}
7
+
8
+module.exports = class MatchMaker {
9
+    constructor(settings) {
10
+        this.proposer = settings.proposer
11
+
12
+        // Score main profile
13
+        this.keeper = new ScoreKeeper()
14
+        this.proposer.score = this.keeper.score(this.proposer)
15
+
16
+        this.profiles = this.getProfilesFor(settings)
17
+    }
18
+    runPrematch(settings) {
19
+        // grab all profiles form the db
20
+
21
+        // grab all responses
22
+        // grab all response keys
23
+        // create a full response object
24
+        // create a full profile of responses
25
+
26
+        const unscreenedProfiles = []
27
+        const screenedProfiles = []
28
+
29
+        for (const profile in unscreenedProfiles) {
30
+            // Do something here
31
+            if (!settings) {
32
+                return
33
+            }
34
+            screenedProfiles.push(profile)
35
+        }
36
+
37
+        return screenedProfiles
38
+    }
39
+    matchFor(proposer, profiles, settings) {
40
+        // Do something here
41
+        return this.runPrematch(profiles, settings)
42
+    }
43
+    scoreProfiles(profiles) {
44
+        const matchScores = []
45
+        for (const profile in this.profiles) {
46
+            const scored = this.keeper.score(profile)
47
+            matchScores.push(scored)
48
+        }
49
+        return matchScores
50
+    }
51
+}

Загрузка…
Отмена
Сохранить