Skip to content

Commit 2925040

Browse files
committed
fix: 스토리에서 rankValue가 에픽이 아닌 프로젝트내에서 고유하도록 수정
- 다른 에픽으로의 스토리 rankValue변경 테스트 삭제 - projectService에서 getAdjustedEpicRankValue함수명을 getAdjustedRankValue으로 변경 - projectService에서 rankValue조정 재시도를 모두 10회로 변경 - 스토리의 rankValue가 프로젝트에서 고유하도록 제약조건 수정
1 parent cc39073 commit 2925040

File tree

4 files changed

+15
-78
lines changed

4 files changed

+15
-78
lines changed

backend/src/project/entity/story.entity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export enum StoryStatus {
1818
}
1919

2020
@Entity()
21-
@Unique('STORY_UQ_RANK_VALUE_AND_EPIC_ID', ['rankValue', 'epicId'])
21+
@Unique('STORY_UQ_RANK_VALUE_AND_PROJECT_ID', ['rankValue', 'projectId'])
2222
export class Story {
2323
@PrimaryGeneratedColumn('increment', { type: 'int' })
2424
id: number;

backend/src/project/project.repository.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -198,17 +198,17 @@ export class ProjectRepository {
198198
} catch (e) {
199199
if (
200200
e.code === 'ER_DUP_ENTRY' &&
201-
e.sqlMessage.includes('STORY_UQ_RANK_VALUE_AND_EPIC_ID')
201+
e.sqlMessage.includes('STORY_UQ_RANK_VALUE_AND_PROJECT_ID')
202202
)
203203
throw new Error('DUPLICATED RANK VALUE');
204204
throw e;
205205
}
206206
}
207207

208-
getNextStoryByRankValue(epicId: number, rankValue: string) {
208+
getNextStoryByRankValue(projectId: number, rankValue: string) {
209209
return this.storyRepository.findOne({
210210
where: {
211-
epicId,
211+
projectId,
212212
rankValue: MoreThan(rankValue),
213213
},
214214
order: { rankValue: 'ASC' },
@@ -259,7 +259,7 @@ export class ProjectRepository {
259259
} catch (e) {
260260
if (
261261
e.code === 'ER_DUP_ENTRY' &&
262-
e.sqlMessage.includes('STORY_UQ_RANK_VALUE_AND_EPIC_ID')
262+
e.sqlMessage.includes('STORY_UQ_RANK_VALUE_AND_PROJECT_ID')
263263
)
264264
throw new Error('DUPLICATED RANK VALUE');
265265
throw e;

backend/src/project/service/project.service.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export class ProjectService {
9797
return result ? true : false;
9898
}
9999

100-
private async getAdjustedEpicRankValue(
100+
private async getAdjustedRankValue(
101101
currentRankValue: string,
102102
nextRankValue: string | null,
103103
): Promise<string> {
@@ -127,7 +127,7 @@ export class ProjectService {
127127
newEpic.projectId,
128128
newEpic.rankValue,
129129
);
130-
newEpic.rankValue = await this.getAdjustedEpicRankValue(
130+
newEpic.rankValue = await this.getAdjustedRankValue(
131131
newEpic.rankValue,
132132
nextEpic?.rankValue,
133133
);
@@ -173,7 +173,7 @@ export class ProjectService {
173173
project.id,
174174
updatedRankValue,
175175
);
176-
updatedRankValue = await this.getAdjustedEpicRankValue(
176+
updatedRankValue = await this.getAdjustedRankValue(
177177
updatedRankValue,
178178
nextEpic?.rankValue,
179179
);
@@ -205,10 +205,10 @@ export class ProjectService {
205205
if (e.message === 'DUPLICATED RANK VALUE') {
206206
const nextStory =
207207
await this.projectRepository.getNextStoryByRankValue(
208-
newStory.epicId,
208+
newStory.projectId,
209209
newStory.rankValue,
210210
);
211-
newStory.rankValue = await this.getAdjustedEpicRankValue(
211+
newStory.rankValue = await this.getAdjustedRankValue(
212212
newStory.rankValue,
213213
nextStory?.rankValue,
214214
);
@@ -239,7 +239,7 @@ export class ProjectService {
239239
if (!epic) throw new Error('epic id not found');
240240
}
241241

242-
const maxRetries = 100;
242+
const maxRetries = 10;
243243
let attempts = 0;
244244

245245
let updatedRankValue = rankValue;
@@ -266,7 +266,7 @@ export class ProjectService {
266266
updatedRankValue,
267267
);
268268

269-
updatedRankValue = await this.getAdjustedEpicRankValue(
269+
updatedRankValue = await this.getAdjustedRankValue(
270270
updatedRankValue,
271271
nextStory?.rankValue,
272272
);
@@ -314,7 +314,7 @@ export class ProjectService {
314314
newTask.storyId,
315315
newTask.rankValue,
316316
);
317-
newTask.rankValue = await this.getAdjustedEpicRankValue(
317+
newTask.rankValue = await this.getAdjustedRankValue(
318318
newTask.rankValue,
319319
nextTask?.rankValue,
320320
);
@@ -347,7 +347,7 @@ export class ProjectService {
347347
if (!story) throw new Error('story id not found');
348348
}
349349

350-
const maxRetries = 100;
350+
const maxRetries = 10;
351351
let attempts = 0;
352352

353353
let updatedRankValue = rankValue;
@@ -375,7 +375,7 @@ export class ProjectService {
375375
updatedRankValue,
376376
);
377377

378-
updatedRankValue = await this.getAdjustedEpicRankValue(
378+
updatedRankValue = await this.getAdjustedRankValue(
379379
updatedRankValue,
380380
nextTask?.rankValue,
381381
);

backend/test/project/ws-backlog-page/ws-story.e2e-spec.ts

Lines changed: 0 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -294,69 +294,6 @@ describe('WS story', () => {
294294
socket.close();
295295
});
296296

297-
it('should return updated story data when update rankValue within different epic', async () => {
298-
const socket = await getMemberJoinedLandingPage();
299-
socket.emit('joinBacklog');
300-
await initBacklog(socket);
301-
302-
const name = '회원';
303-
const color = 'yellow';
304-
const middleRankValue = LexoRank.middle().toString();
305-
306-
const requestData1: any = {
307-
action: 'create',
308-
content: { name, color, rankValue: middleRankValue },
309-
};
310-
socket.emit('epic', requestData1);
311-
const epicId1 = await getEpicId(socket);
312-
313-
const requestData2: any = {
314-
action: 'create',
315-
content: {
316-
name,
317-
color,
318-
rankValue: LexoRank.parse(middleRankValue).genNext().toString(),
319-
},
320-
};
321-
socket.emit('epic', requestData2);
322-
const epicId2 = await getEpicId(socket);
323-
324-
const title = '타이틀';
325-
const point = 2;
326-
const status = '시작전';
327-
const requestData3 = {
328-
action: 'create',
329-
content: {
330-
title,
331-
point,
332-
status,
333-
epicId: epicId1,
334-
rankValue: middleRankValue,
335-
},
336-
};
337-
socket.emit('story', requestData3);
338-
const storyId = await getStoryId(socket);
339-
340-
//변경햘 에픽에서의 첫번째 스토리이기 때문에 middle 메서드를 사용한다.
341-
const newRankValue = LexoRank.middle().toString();
342-
const requestData4 = {
343-
action: 'update',
344-
content: { id: storyId, epicId: epicId2, rankValue: newRankValue },
345-
};
346-
socket.emit('story', requestData4);
347-
await new Promise<void>((resolve) => {
348-
socket.once('backlog', (data) => {
349-
const { content, action, domain } = data;
350-
expect(domain).toBe('story');
351-
expect(action).toBe('update');
352-
expect(content?.id).toBe(storyId);
353-
expect(content?.rankValue).toBe(newRankValue);
354-
resolve();
355-
});
356-
});
357-
socket.close();
358-
});
359-
360297
it('should return updated story data when updating multiple stories simultaneously', async () => {
361298
const socket = await getMemberJoinedLandingPage();
362299
socket.emit('joinBacklog');

0 commit comments

Comments
 (0)