Explorar el Código

postMembershipByProfileId added to ProfileCardList

tags/0.0.1
diaseu hace 4 años
padre
commit
a4569093ef

+ 1
- 0
frontend/src/components/ProfileCardList.vue Ver fichero

77
     const targetId = props.profiles[0].uid
77
     const targetId = props.profiles[0].uid
78
     updateQueueByProfileId(profileId, targetId, false)
78
     updateQueueByProfileId(profileId, targetId, false)
79
     // TODO: next step is grouping/membership
79
     // TODO: next step is grouping/membership
80
+    postMembershipByProfileId({ profileId, targetId })
80
 }
81
 }
81
 const hold = () => {
82
 const hold = () => {
82
     console.log('held? do we need this?')
83
     console.log('held? do we need this?')

+ 10
- 2
frontend/src/components/form.vue Ver fichero

58
 import { validatorMapping, makeKebob } from '@/utils'
58
 import { validatorMapping, makeKebob } from '@/utils'
59
 import { defineProps, reactive, ref } from 'vue'
59
 import { defineProps, reactive, ref } from 'vue'
60
 import { saveSurveyByProfileID, scoreSurveyByProfileId } from '../services/survey.service'
60
 import { saveSurveyByProfileID, scoreSurveyByProfileId } from '../services/survey.service'
61
+import { fetchMembershipsByProfileId, postMembershipByProfileId } from '../services/grouping.service'
61
 
62
 
62
 const slidevalue = ref('0')
63
 const slidevalue = ref('0')
63
 
64
 
128
         // Bc we don't want to pass the 1st question to backend & we want profileId
129
         // Bc we don't want to pass the 1st question to backend & we want profileId
129
         // Necessary atm bc we manually added question in Survey class (entity)
130
         // Necessary atm bc we manually added question in Survey class (entity)
130
         const profileId = idWithResponseVal.shift().val
131
         const profileId = idWithResponseVal.shift().val
131
-        // TODO: pass maxDistance from an input value somewhere later
132
+        const targetId = 0
132
         const maxDistance = 10
133
         const maxDistance = 10
133
         saveSurveyByProfileID(idWithResponseVal, profileId)
134
         saveSurveyByProfileID(idWithResponseVal, profileId)
134
         alert('Responses submitted!')
135
         alert('Responses submitted!')
135
         resetAnswers()
136
         resetAnswers()
136
-        // TODO: score here after save survey responses
137
         scoreSurveyByProfileId(profileId, maxDistance)
137
         scoreSurveyByProfileId(profileId, maxDistance)
138
+
139
+        const checkMembership = fetchMembershipsByProfileId(profileId)
140
+        console.log(checkMembership)
141
+        if (!checkMembership) {
142
+            console.log('Make membership')
143
+            // postMembershipByProfileId({ profileId, targetId })
144
+        }
145
+
138
         state.step = 1
146
         state.step = 1
139
     } else if (state.step < props.form.length) {
147
     } else if (state.step < props.form.length) {
140
         state.step++
148
         state.step++

+ 3
- 1
frontend/src/services/grouping.service.js Ver fichero

25
     targetId,
25
     targetId,
26
     groupingType = 'match',
26
     groupingType = 'match',
27
 }) => {
27
 }) => {
28
+    const utcDateInSeconds = Date.now()/1000
28
     const membership = {
29
     const membership = {
29
         target_id: targetId,
30
         target_id: targetId,
30
         grouping_type: groupingType,
31
         grouping_type: groupingType,
31
-        grouping_name: `delete_${profileId}_${targetId}`,
32
+        grouping_name: `${utcDateInSeconds}_${profileId}_${targetId}`,
32
     }
33
     }
34
+    console.log('Membership Created')
33
     const createdMembershipRecord = await db.post(
35
     const createdMembershipRecord = await db.post(
34
         `/membership/${profileId}/join`,
36
         `/membership/${profileId}/join`,
35
         membership,
37
         membership,

+ 4
- 0
frontend/src/views/home.vue Ver fichero

12
 import mainNav from '../components/MainNav.vue'
12
 import mainNav from '../components/MainNav.vue'
13
 import profileCardList from '../components/ProfileCardList.vue'
13
 import profileCardList from '../components/ProfileCardList.vue'
14
 import { fetchQueueByProfileId } from '../services'
14
 import { fetchQueueByProfileId } from '../services'
15
+import { fetchMembershipsByProfileId, postMembershipByProfileId } from '../services/grouping.service'
15
 
16
 
16
 import batch_10 from '../../../backend/db/generated/_batch_10.js.ref'
17
 import batch_10 from '../../../backend/db/generated/_batch_10.js.ref'
17
 import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
18
 import batch_20 from '../../../backend/db/generated/_batch_20.js.ref'
35
         const queueList = await fetchQueueByProfileId(this.mypid)
36
         const queueList = await fetchQueueByProfileId(this.mypid)
36
         console.log('queueList', queueList)
37
         console.log('queueList', queueList)
37
         this.processQueue(queueList)
38
         this.processQueue(queueList)
39
+        const profileId = 38
40
+        const checkMembership = fetchMembershipsByProfileId(profileId)
41
+        console.log('checkMembership', checkMembership)
38
     },
42
     },
39
     methods: {
43
     methods: {
40
         processQueue(queueList) {
44
         processQueue(queueList) {

Loading…
Cancelar
Guardar