@trafficgroup/knex-rel 0.1.5 → 0.1.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dao/folder/folder.dao.js +3 -6
- package/dist/dao/folder/folder.dao.js.map +1 -1
- package/dist/dao/report-configuration/report-configuration.dao.d.ts +8 -0
- package/dist/dao/report-configuration/report-configuration.dao.js +19 -0
- package/dist/dao/report-configuration/report-configuration.dao.js.map +1 -1
- package/dist/dao/study/study.dao.d.ts +1 -0
- package/dist/dao/study/study.dao.js +18 -3
- package/dist/dao/study/study.dao.js.map +1 -1
- package/dist/dao/video/video.dao.d.ts +0 -9
- package/dist/dao/video/video.dao.js +0 -51
- package/dist/dao/video/video.dao.js.map +1 -1
- package/dist/interfaces/folder/folder.interfaces.d.ts +0 -3
- package/dist/interfaces/study/study.interfaces.d.ts +5 -0
- package/dist/interfaces/video/video.interfaces.d.ts +0 -3
- package/migrations/20251010143500_migration.ts +83 -0
- package/package.json +1 -1
- package/src/dao/folder/folder.dao.ts +3 -18
- package/src/dao/report-configuration/report-configuration.dao.ts +25 -0
- package/src/dao/study/study.dao.ts +34 -3
- package/src/dao/video/video.dao.ts +0 -63
- package/src/interfaces/folder/folder.interfaces.ts +0 -3
- package/src/interfaces/study/study.interfaces.ts +5 -0
- package/src/interfaces/video/video.interfaces.ts +0 -3
- package/plan.md +0 -831
|
@@ -257,67 +257,4 @@ export class VideoDAO implements IBaseDAO<IVideo> {
|
|
|
257
257
|
|
|
258
258
|
return rows.map((row) => row.id);
|
|
259
259
|
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Bulk update camera assignment for multiple videos
|
|
263
|
-
* Supports optional transaction for service-level transaction management
|
|
264
|
-
*/
|
|
265
|
-
async bulkUpdateCamera(
|
|
266
|
-
videoIds: number[],
|
|
267
|
-
cameraId: number | null,
|
|
268
|
-
trx?: Knex.Transaction,
|
|
269
|
-
): Promise<number> {
|
|
270
|
-
if (!videoIds || videoIds.length === 0) {
|
|
271
|
-
return 0;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const query = trx || this._knex;
|
|
275
|
-
|
|
276
|
-
const result = await query("video")
|
|
277
|
-
.whereIn("id", videoIds)
|
|
278
|
-
.update({
|
|
279
|
-
cameraId: cameraId,
|
|
280
|
-
updated_at: query.fn.now(),
|
|
281
|
-
})
|
|
282
|
-
.returning("id");
|
|
283
|
-
|
|
284
|
-
return result.length;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* Get videos by camera ID with folder information (paginated)
|
|
289
|
-
*/
|
|
290
|
-
async getVideosByCameraIdWithFolder(
|
|
291
|
-
cameraId: number,
|
|
292
|
-
page: number,
|
|
293
|
-
limit: number,
|
|
294
|
-
): Promise<IDataPaginator<IVideo>> {
|
|
295
|
-
const offset = (page - 1) * limit;
|
|
296
|
-
|
|
297
|
-
const query = this._knex("video as v")
|
|
298
|
-
.innerJoin("folders as f", "v.folderId", "f.id")
|
|
299
|
-
.select("v.*", this._knex.raw("to_jsonb(f.*) as folder"))
|
|
300
|
-
.where("v.cameraId", cameraId);
|
|
301
|
-
|
|
302
|
-
// Optimized count query without JOIN
|
|
303
|
-
const [countResult] = await this._knex("video as v")
|
|
304
|
-
.where("v.cameraId", cameraId)
|
|
305
|
-
.count("* as count");
|
|
306
|
-
const totalCount = +countResult.count;
|
|
307
|
-
const videos = await query
|
|
308
|
-
.clone()
|
|
309
|
-
.limit(limit)
|
|
310
|
-
.offset(offset)
|
|
311
|
-
.orderBy("v.created_at", "desc");
|
|
312
|
-
|
|
313
|
-
return {
|
|
314
|
-
success: true,
|
|
315
|
-
data: videos,
|
|
316
|
-
page,
|
|
317
|
-
limit,
|
|
318
|
-
count: videos.length,
|
|
319
|
-
totalCount,
|
|
320
|
-
totalPages: Math.ceil(totalCount / limit),
|
|
321
|
-
};
|
|
322
|
-
}
|
|
323
260
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { IStudy } from "../study/study.interfaces";
|
|
2
|
-
import type { ICamera } from "../camera/camera.interfaces";
|
|
3
2
|
|
|
4
3
|
export interface IFolder {
|
|
5
4
|
id: number;
|
|
@@ -8,9 +7,7 @@ export interface IFolder {
|
|
|
8
7
|
createdBy: number; // user.id
|
|
9
8
|
status: "UPLOADING" | "COMPLETE";
|
|
10
9
|
studyId: number; // study.id
|
|
11
|
-
cameraId?: number; // camera.id
|
|
12
10
|
created_at: string;
|
|
13
11
|
updated_at: string;
|
|
14
12
|
study?: IStudy;
|
|
15
|
-
camera?: ICamera;
|
|
16
13
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { IUser } from "../user/user.interfaces";
|
|
2
|
+
import type { ICamera } from "../camera/camera.interfaces";
|
|
2
3
|
|
|
3
4
|
export interface IStudy {
|
|
4
5
|
id: number;
|
|
5
6
|
uuid: string;
|
|
6
7
|
name: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
type: "TMC" | "ATR";
|
|
7
10
|
createdBy: number;
|
|
11
|
+
cameraId?: number;
|
|
8
12
|
status: "COMPLETE" | "IN PROGRESS" | "FAILED";
|
|
9
13
|
created_at: string;
|
|
10
14
|
updated_at: string;
|
|
11
15
|
user?: IUser;
|
|
16
|
+
camera?: ICamera;
|
|
12
17
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import type { IFolder } from "../folder/folder.interfaces";
|
|
2
|
-
import type { ICamera } from "../camera/camera.interfaces";
|
|
3
2
|
|
|
4
3
|
export interface IVideo {
|
|
5
4
|
id: number;
|
|
6
5
|
uuid: string;
|
|
7
6
|
folderId: number;
|
|
8
|
-
cameraId?: number;
|
|
9
7
|
annotationSourceId?: number;
|
|
10
8
|
name: string;
|
|
11
9
|
videoLocation: string;
|
|
@@ -31,5 +29,4 @@ export interface IVideo {
|
|
|
31
29
|
created_at: string;
|
|
32
30
|
updated_at: string;
|
|
33
31
|
folder?: IFolder;
|
|
34
|
-
camera?: ICamera;
|
|
35
32
|
}
|