Merged PR 745: タスク取得処理のクエリ発行箇所の修正
## 概要 [Task3673: タスク取得処理のクエリ発行箇所の修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3673) - タスク取得時にRelationでOptionItemも取得しているが、そのJoinカラムの指定方法に誤りがあったため正しいジョインカラムを指定するように修正した。 - 本来はタスクレコードのaudio_file_idとOptionItemのaudio_file_idでjoinするはずだが、タスクレコードのidとOptionItemのaudio_file_idでjoinしていた - タスクと音声ファイルは同時にレコードが作られるため基本的にidが一致する傾向があり、テストで発見できていなかった模様 - https://orkhan.gitbook.io/typeorm/docs/relations#joincolumn-options - テスト修正 ## レビューポイント - 特になし ## UIの変更 ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば
This commit is contained in:
parent
9cc9a3bd94
commit
73ef74770e
@ -11,6 +11,7 @@ import { makeErrorResponse } from '../../common/error/makeErrorResponse';
|
||||
import { TasksService } from './tasks.service';
|
||||
import { DataSource } from 'typeorm';
|
||||
import {
|
||||
createAudioFile,
|
||||
createCheckoutPermissions,
|
||||
createTask,
|
||||
createUserGroup,
|
||||
@ -703,6 +704,19 @@ describe('TasksService', () => {
|
||||
role: 'author',
|
||||
author_id: 'MY_AUTHOR_ID',
|
||||
});
|
||||
|
||||
//「バグ 3661: [FB対応]Option Itemにチェックを付けると真っ白な画面になる」の確認のため
|
||||
// audio_file_idをTaskIdと異なる値にするために、AudioFileを作成
|
||||
await createAudioFile(
|
||||
source,
|
||||
accountId,
|
||||
userId,
|
||||
'MY_AUTHOR_ID',
|
||||
'',
|
||||
'00',
|
||||
);
|
||||
|
||||
// Taskを作成
|
||||
await createTask(
|
||||
source,
|
||||
accountId,
|
||||
@ -746,10 +760,26 @@ describe('TasksService', () => {
|
||||
{
|
||||
const task = tasks[0];
|
||||
expect(task.jobNumber).toEqual('00000001');
|
||||
// AudioOptionItem
|
||||
const audioOptionItems = Array.from({ length: 10 }).map((_, i) => {
|
||||
return {
|
||||
optionItemLabel: `label${i}:audio_file_id${task.audioFileId}`,
|
||||
optionItemValue: `value${i}:audio_file_id${task.audioFileId}`,
|
||||
};
|
||||
});
|
||||
expect(task.optionItemList).toEqual(audioOptionItems);
|
||||
}
|
||||
{
|
||||
const task = tasks[1];
|
||||
expect(task.jobNumber).toEqual('00000002');
|
||||
// AudioOptionItem
|
||||
const audioOptionItems = Array.from({ length: 10 }).map((_, i) => {
|
||||
return {
|
||||
optionItemLabel: `label${i}:audio_file_id${task.audioFileId}`,
|
||||
optionItemValue: `value${i}:audio_file_id${task.audioFileId}`,
|
||||
};
|
||||
});
|
||||
expect(task.optionItemList).toEqual(audioOptionItems);
|
||||
}
|
||||
});
|
||||
it('[Author] Authorは同一アカウントであっても自分以外のAuhtorのTaskは取得できない', async () => {
|
||||
|
||||
@ -38,6 +38,7 @@ import {
|
||||
NotificationhubServiceMockValue,
|
||||
makeNotificationhubServiceMock,
|
||||
} from './tasks.service.mock';
|
||||
import { AudioOptionItem } from '../../../repositories/audio_option_items/entity/audio_option_item.entity';
|
||||
|
||||
export const makeTaskTestingModuleWithNotificaiton = async (
|
||||
datasource: DataSource,
|
||||
@ -130,6 +131,18 @@ export const createTask = async (
|
||||
audio_format: 'audio_format',
|
||||
is_encrypted: true,
|
||||
});
|
||||
// AudioOptionItemを10個作成
|
||||
const audioOptionItems = Array.from({ length: 10 }).map((_, i) => {
|
||||
return {
|
||||
audio_file_id: audioFileIdentifiers[0].id,
|
||||
label: `label${i}:audio_file_id${audioFileIdentifiers[0].id}`,
|
||||
value: `value${i}:audio_file_id${audioFileIdentifiers[0].id}`,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
await datasource.getRepository(AudioOptionItem).insert(audioOptionItems);
|
||||
|
||||
const audioFile = audioFileIdentifiers.pop() as AudioFile;
|
||||
const { identifiers: taskIdentifiers } = await datasource
|
||||
.getRepository(Task)
|
||||
@ -147,6 +160,37 @@ export const createTask = async (
|
||||
const task = taskIdentifiers.pop() as Task;
|
||||
return { taskId: task.id, audioFileId: audioFile.id };
|
||||
};
|
||||
|
||||
export const createAudioFile = async(
|
||||
datasource: DataSource,
|
||||
account_id: number,
|
||||
owner_user_id: number,
|
||||
author_id: string,
|
||||
work_type_id: string,
|
||||
priority: string,
|
||||
): Promise<{ audioFileId: number }> => {
|
||||
const { identifiers: audioFileIdentifiers } = await datasource
|
||||
.getRepository(AudioFile)
|
||||
.insert({
|
||||
account_id: account_id,
|
||||
owner_user_id: owner_user_id,
|
||||
url: '',
|
||||
file_name: 'x.zip',
|
||||
author_id: author_id,
|
||||
work_type_id: work_type_id,
|
||||
started_at: new Date(),
|
||||
duration: '100000',
|
||||
finished_at: new Date(),
|
||||
uploaded_at: new Date(),
|
||||
file_size: 10000,
|
||||
priority: priority,
|
||||
audio_format: 'audio_format',
|
||||
is_encrypted: true,
|
||||
});
|
||||
const audioFile = audioFileIdentifiers.pop() as AudioFile;
|
||||
return { audioFileId: audioFile.id };
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param datasource
|
||||
|
||||
@ -18,6 +18,6 @@ export class AudioOptionItem {
|
||||
@Column()
|
||||
value: string;
|
||||
@ManyToOne(() => Task, (task) => task.audio_file_id)
|
||||
@JoinColumn({ name: 'audio_file_id' })
|
||||
@JoinColumn({ name: 'audio_file_id', referencedColumnName: 'audio_file_id' })
|
||||
task: Task | null;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user