Skip to content

Commit 61fe685

Browse files
committed
Merge pull request #61 from CS3219-AY2425S1/release/milestone-4
2 parents b3c2ee8 + f3799bc commit 61fe685

File tree

3 files changed

+11
-82
lines changed

3 files changed

+11
-82
lines changed
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
1-
import axios from 'axios';
2-
3-
import { PEERPREP_COLLAB_HOST } from '@/config';
1+
import crypto from 'crypto';
42

53
export async function createRoom(
64
userId1: string,
75
userId2: string,
86
questionId: string
97
): Promise<string> {
10-
const response = await axios.get<{ roomName: string }>(`${PEERPREP_COLLAB_HOST}/room`, {
11-
params: {
12-
userid1: userId1,
13-
userid2: userId2,
14-
questionid: questionId,
15-
},
16-
});
17-
18-
if (response.status !== 200 || !response.data?.roomName) {
19-
throw new Error('Failed to create room');
20-
}
21-
22-
return response.data.roomName;
8+
const combinedString = `uid1=${userId1}|uid2=${userId2}|qid=${questionId}`;
9+
const hash = crypto.createHash('sha256');
10+
const uniqueRoomName = hash.update(combinedString).digest('hex');
11+
return uniqueRoomName;
2312
}

backend/matching/src/workers/matcher.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,11 @@ async function match() {
149149
} as const;
150150
const requestorParams = { requestorUserId, requestorStreamId, requestorSocketPort };
151151

152-
const exactMatches = await redisClient.ft.search(POOL_INDEX, clause.join(' '), searchParams);
152+
const exactMatches = await redisClient.ft.search(
153+
POOL_INDEX,
154+
clause.reverse().join(' '),
155+
searchParams
156+
);
153157
const exactMatchFound = await processMatch(
154158
redisClient,
155159
requestorParams,
@@ -186,7 +190,7 @@ async function match() {
186190
// Match on Difficulty
187191
const difficultyMatches = await redisClient.ft.search(
188192
POOL_INDEX,
189-
`@difficulty:${difficulty} -@userId:(${requestorUserId})`,
193+
`@difficulty:{${difficulty}} -@userId:(${requestorUserId})`,
190194
searchParams
191195
);
192196
const hasDifficultyMatch = await processMatch(

docker-compose.yaml

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,6 @@ services:
4242
start_period: 30s
4343
timeout: 10s
4444

45-
collab-db:
46-
hostname: 'collab-db'
47-
image: postgres:16.4
48-
container_name: 'collab-db'
49-
env_file:
50-
- ./backend/collaboration/.env.local
51-
volumes:
52-
- 'collab-db-docker:${COLLAB_PGDATA}'
53-
restart: unless-stopped
54-
networks:
55-
- collab-db-network
56-
healthcheck:
57-
test: ['CMD-SHELL', 'pg_isready -U peerprep-collab-express -d collab']
58-
interval: 10s
59-
retries: 5
60-
start_period: 30s
61-
timeout: 10s
62-
6345
match-db:
6446
hostname: 'match-db'
6547
# To enable Admin UI for cluster ↙️
@@ -139,37 +121,6 @@ services:
139121
retries: 5
140122
start_period: 5s
141123

142-
collab-service:
143-
image: 'collab-express'
144-
container_name: '${COLLAB_SERVICE_NAME}'
145-
build:
146-
context: ./backend/collaboration
147-
dockerfile: express.Dockerfile
148-
target: production
149-
args:
150-
# For building with the correct env vars
151-
- port=${COLLAB_EXPRESS_PORT}
152-
env_file:
153-
- ./backend/collaboration/.env.compose
154-
environment:
155-
# Docker Compose Specific for Service Discovery
156-
- EXPRESS_DB_HOST=collab-db
157-
- EXPRESS_DB_PORT=5432
158-
- PEERPREP_UI_HOST=http://${FRONTEND_SERVICE_NAME}:${FRONTEND_PORT}
159-
depends_on:
160-
collab-db:
161-
condition: service_healthy
162-
restart: true
163-
networks:
164-
- collab-db-network
165-
- collab-api-network
166-
healthcheck:
167-
test: wget --no-verbose --tries=1 --spider http://localhost:${COLLAB_EXPRESS_PORT}/health || exit 1
168-
interval: 30s
169-
timeout: 10s
170-
retries: 5
171-
start_period: 5s
172-
173124
matching-service:
174125
image: 'match-express'
175126
container_name: '${MATCHING_SERVICE_NAME}'
@@ -189,18 +140,15 @@ services:
189140
- PEERPREP_UI_HOST=http://${FRONTEND_SERVICE_NAME}:${FRONTEND_PORT}
190141
- PEERPREP_USER_HOST=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
191142
- PEERPREP_QUESTION_HOST=http://${QUESTION_SERVICE_NAME}:${QUESTION_EXPRESS_PORT}
192-
- PEERPREP_COLLAB_HOST=http://${COLLAB_SERVICE_NAME}:${COLLAB_EXPRESS_PORT}
193143
depends_on:
194144
- match-db
195145
- user-service
196146
- question-service
197-
- collab-service
198147
networks:
199148
- match-db-network
200149
- match-api-network
201150
- user-api-network
202151
- question-api-network
203-
- collab-api-network
204152
healthcheck:
205153
test: wget --no-verbose --tries=1 --spider http://localhost:${MATCHING_EXPRESS_PORT}/health || exit 1
206154
interval: 30s
@@ -225,7 +173,6 @@ services:
225173
environment:
226174
- VITE_USER_SERVICE=http://${USER_SERVICE_NAME}:${USER_EXPRESS_PORT}
227175
- VITE_QUESTION_SERVICE=http://${QUESTION_SERVICE_NAME}:${QUESTION_EXPRESS_PORT}
228-
- VITE_COLLAB_SERVICE=http://${COLLAB_SERVICE_NAME}:${COLLAB_EXPRESS_PORT}
229176
- VITE_MATCHING_SERVICE=http://${MATCHING_SERVICE_NAME}:${MATCHING_EXPRESS_PORT}
230177
- FRONTEND_PORT=${FRONTEND_PORT}
231178
depends_on:
@@ -235,16 +182,12 @@ services:
235182
question-service:
236183
condition: service_healthy
237184
restart: true
238-
collab-service:
239-
condition: service_healthy
240-
restart: true
241185
matching-service:
242186
condition: service_healthy
243187
restart: true
244188
networks:
245189
- user-api-network
246190
- question-api-network
247-
- collab-api-network
248191
- match-api-network
249192

250193
volumes:
@@ -253,9 +196,6 @@ volumes:
253196
external: true
254197
question-db-docker:
255198
external: true
256-
# Collab WS Server
257-
collab-db-docker:
258-
external: true
259199
# Redis Match server
260200
match-db-docker:
261201
external: true
@@ -268,8 +208,6 @@ networks:
268208
driver: bridge
269209
match-db-network:
270210
driver: bridge
271-
collab-db-network:
272-
driver: bridge
273211

274212
# View-Controller Networks
275213
user-api-network:
@@ -278,5 +216,3 @@ networks:
278216
driver: bridge
279217
match-api-network:
280218
driver: bridge
281-
collab-api-network:
282-
driver: bridge

0 commit comments

Comments
 (0)