Skip to content

Commit a8e5861

Browse files
committed
OV-352: * small fixes
1 parent 64f8f43 commit a8e5861

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

backend/src/bundles/videos/video.repository.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class VideoRepository implements Repository {
1212

1313
public async findById(id: string): Promise<VideoEntity | null> {
1414
const video = await this.videoModel.query().findById(id).execute();
15+
1516
return video ? VideoEntity.initialize(video) : null;
1617
}
1718

@@ -20,28 +21,32 @@ class VideoRepository implements Repository {
2021
.query()
2122
.where('userId', userId)
2223
.execute();
24+
2325
return videos.map((it) => VideoEntity.initialize(it));
2426
}
2527

2628
public async findAll(): Promise<VideoEntity[]> {
2729
const videos = await this.videoModel.query().execute();
30+
2831
return videos.map((it) => VideoEntity.initialize(it));
2932
}
3033

3134
public async create(entity: VideoEntity): Promise<VideoEntity> {
3235
const { userId, name, url, composition, previewUrl } =
3336
entity.toNewObject();
37+
3438
const item = await this.videoModel
3539
.query()
3640
.insert({
3741
userId,
3842
name,
39-
composition: composition,
43+
composition,
4044
previewUrl,
4145
url,
4246
})
4347
.returning('*')
4448
.execute();
49+
4550
return VideoEntity.initialize(item);
4651
}
4752

@@ -50,20 +55,25 @@ class VideoRepository implements Repository {
5055
payload: UpdateVideoRequestDto,
5156
): Promise<VideoEntity | null> {
5257
const data: Partial<VideoModel> = {};
58+
5359
if (payload.composition) {
5460
data.composition = payload.composition;
5561
data.previewUrl = payload.composition.scenes[0]?.avatar?.url ?? '';
5662
}
63+
5764
if (payload.name) {
5865
data.name = payload.name;
5966
}
67+
6068
if (payload.url) {
6169
data.url = payload.url;
6270
}
71+
6372
const updatedItem = await this.videoModel
6473
.query()
6574
.patchAndFetchById(id, data)
6675
.execute();
76+
6777
return updatedItem ? VideoEntity.initialize(updatedItem) : null;
6878
}
6979

@@ -72,6 +82,7 @@ class VideoRepository implements Repository {
7282
.query()
7383
.deleteById(id)
7484
.execute();
85+
7586
return Boolean(numberOfDeletedRows);
7687
}
7788
}

backend/src/bundles/videos/video.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class VideoService implements Service {
6060
VideoEntity.initializeNew({
6161
name: payload.name,
6262
composition: payload.composition,
63-
previewUrl: payload.composition?.scenes[0]?.avatar?.url || '',
63+
previewUrl: payload.composition?.scenes[0]?.avatar?.url ?? '',
6464
userId: payload.userId,
6565
}),
6666
);

0 commit comments

Comments
 (0)