Merged PR 1057: File Lengthのソートが正しく行われない_実装

## 概要
[タスク 4657: FB対応: File Lengthのソートが正しく行われない](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/OMDSDictation-2nd/_sprints/taskboard/OMDSDictation-2nd%20%E3%83%81%E3%83%BC%E3%83%A0/OMDSDictation-2nd/FY25_%E4%BF%9D%E5%AE%884%E6%9C%88?workitem=4657)

録音時間が文字列で登録されていたため、FileLengthが正しくソートされていなかった。
DBのaudio_filesテーブルのデータ型を文字列から数値型に変更する修正をいたしました。

数値型に変更にともない
カラムデータ型変更のためマイグレーションファイルを追加しております
durationを文字列で型宣言している部分の修正
型変更に伴う影響がある部分を修正しております。

## 動作確認状況
[単体テスト_File Lengthのソートが正しく行われない_実装](https://ndstokyo.sharepoint.com//r/sites/SNC-OMDS/Shared%20Documents/%E4%BF%9D%E5%AE%88/10_%E3%83%86%E3%82%B9%E3%83%88%E9%96%A2%E9%80%A3/%E5%8D%98%E4%BD%93%E3%83%86%E3%82%B9%E3%83%88/%E3%82%BF%E3%82%B9%E3%82%AF4657_File%20Length%E3%81%AE%E3%82%BD%E3%83%BC%E3%83%88%E3%81%8C%E6%AD%A3%E3%81%97%E3%81%8F%E8%A1%8C%E3%82%8F%E3%82%8C%E3%81%AA%E3%81%84_%E5%AE%9F%E8%A3%85/%E5%8D%98%E4%BD%93%E3%83%86%E3%82%B9%E3%83%88%E3%82%A8%E3%83%93%E3%83%87%E3%83%B3%E3%82%B9_%E3%82%BF%E3%82%B9%E3%82%AF4657_FB%E5%AF%BE%E5%BF%9C_File%20Length%E3%81%AE%E3%82%BD%E3%83%BC%E3%83%88%E3%81%8C%E6%AD%A3%E3%81%97%E3%81%8F%E8%A1%8C%E3%82%8F%E3%82%8C%E3%81%AA%E3%81%84.xlsx?d=wd663d69da107438496581c251a6072ff&csf=1&web=1&e=RdF4XS)

ユニットテスト実行結果
```
Test Suites: 24 passed, 24 total
Tests:       690 passed, 690 total
Snapshots:   0 total
Time:        2095.039 s, estimated 3500 s
```
This commit is contained in:
金村 勇祐 2025-04-23 02:04:28 +00:00
parent 8d6aa6117c
commit d9d6ccd60f
11 changed files with 319 additions and 311 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
-- +migrate Up
ALTER TABLE `audio_files`
MODIFY COLUMN `duration` BIGINT UNSIGNED NOT NULL COMMENT '録音時間';
-- +migrate Down
ALTER TABLE `audio_files`
MODIFY COLUMN `duration` VARCHAR(255) NOT NULL COMMENT '録音時間';

View File

@ -247,7 +247,7 @@ export const createAudioFile = async (
author_id: 'author_id',
work_type_id: '',
started_at: new Date(),
duration: '100000',
duration: 100000,
finished_at: new Date(),
uploaded_at: new Date(),
file_size: fileSize,

View File

@ -351,7 +351,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -457,7 +457,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -584,7 +584,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
'XXXXXX', // 存在しないAuthorIDを指定
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -644,7 +644,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -723,7 +723,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -832,7 +832,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -922,7 +922,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1011,7 +1011,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1105,7 +1105,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '', // 音声ファイルの情報には、録音者のAuthorIDが入る
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1148,7 +1148,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'yyyy-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1192,7 +1192,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1233,7 +1233,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
'authorAuthorId',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1284,7 +1284,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1395,7 +1395,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1514,7 +1514,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1643,7 +1643,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1772,7 +1772,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -1891,7 +1891,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -2038,7 +2038,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -2188,7 +2188,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
@ -2338,7 +2338,7 @@ describe('タスク作成から自動ルーティング(DB使用)', () => {
'http://blob/url/file.zip',
authorAuthorId ?? '',
'file.zip',
'11:22:33',
"100000",
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',
'2023-05-26T11:22:33.444',

View File

@ -69,7 +69,7 @@ export const createTask = async (
author_id: author_id ?? 'DEFAULT_ID',
work_type_id: 'work_type_id',
started_at: new Date(),
duration: '100000',
duration: 100000,
finished_at: new Date(),
uploaded_at: new Date(),
file_size: fileSize ?? 10000,

View File

@ -264,7 +264,7 @@ describe('TasksService', () => {
author_id: 'AUTHOR',
work_type_id: 'WorkType',
started_at: new Date('2023-01-01T01:01:01.000'),
duration: '123000',
duration: 123000,
finished_at: new Date('2023-01-01T01:01:01.000'),
uploaded_at: new Date('2023-01-01T01:01:01.000'),
file_size: 123000,

View File

@ -465,7 +465,7 @@ const defaultTasksRepositoryMockValue: {
author_id: 'AUTHOR',
work_type_id: 'WorkType',
started_at: new Date('2023-01-01T01:01:01.000Z'),
duration: '123000',
duration: 123000,
finished_at: new Date('2023-01-01T01:01:01.000Z'),
uploaded_at: new Date('2023-01-01T01:01:01.000Z'),
file_size: 123000,

View File

@ -127,7 +127,7 @@ export const createTask = async (
author_id: author_id,
work_type_id: work_type_id,
started_at: new Date(),
duration: '100000',
duration: 100000,
finished_at: new Date(),
uploaded_at: new Date(),
file_size: 10000,
@ -183,7 +183,7 @@ export const createAudioFile = async (
author_id: author_id,
work_type_id: work_type_id,
started_at: new Date(),
duration: '100000',
duration: 100000,
finished_at: new Date(),
uploaded_at: new Date(),
file_size: 10000,

View File

@ -60,7 +60,7 @@ const createTask = (
authorId: file.author_id,
workType: file.work_type_id,
audioCreatedDate: file.started_at.toISOString(),
audioDuration: file.duration,
audioDuration: file.duration.toString(),
audioFinishedDate: file.finished_at.toISOString(),
audioUploadedDate: file.uploaded_at.toISOString(),
audioFormat: file.audio_format,

View File

@ -23,7 +23,7 @@ export class AudioFile {
@Column()
started_at: Date;
@Column({ type: 'time' })
duration: string;
duration: number;
@Column()
finished_at: Date;
@Column()

View File

@ -1028,7 +1028,8 @@ export class TasksRepositoryService {
audioFile.author_id = author_id;
audioFile.work_type_id = work_type_id;
audioFile.started_at = started_at;
audioFile.duration = duration;
// 数値型のdurationカラムにinsertするため文字列から数値型に変換する
audioFile.duration = parseInt(duration, 10);
audioFile.finished_at = finished_at;
audioFile.uploaded_at = uploaded_at;
audioFile.file_size = file_size;