refactor: implement project package segment lazy select
This commit is contained in:
@@ -1,55 +1,11 @@
|
||||
import axiosClient from '../axios/axios';
|
||||
import { API_ROUTES } from '@/constants/apiRoutes';
|
||||
import { CompletedVideoResult, Video, PaginationParams } from '@/types';
|
||||
import { CompletedVideoResult } from '@/types';
|
||||
|
||||
/**
|
||||
* Video Service
|
||||
*/
|
||||
export const videoService = {
|
||||
/**
|
||||
* Fetch all videos and transform them to match the Video interface
|
||||
*/
|
||||
getVideos: async (params?: PaginationParams): Promise<Video[]> => {
|
||||
const skip = params?.skip ?? 0;
|
||||
const limit = params?.limit ?? 100;
|
||||
|
||||
const response = await axiosClient.get<{
|
||||
videos: Array<{
|
||||
video_id: string;
|
||||
status: string;
|
||||
progress: number;
|
||||
summary?: {
|
||||
unique_defected_sign_board?: number;
|
||||
unique_pothole?: number;
|
||||
unique_road_crack?: number;
|
||||
unique_damaged_road_marking?: number;
|
||||
unique_good_sign_board?: number;
|
||||
total_road_damage?: number;
|
||||
total_detections?: number;
|
||||
};
|
||||
}>;
|
||||
}>(API_ROUTES.VIDEOS.LIST, {
|
||||
params: { skip, limit },
|
||||
});
|
||||
|
||||
// Transform the response to match our Video interface
|
||||
return response.data.videos.map((v) => ({
|
||||
id: v.video_id,
|
||||
filename: v.video_id,
|
||||
detection_type: 'pot-sign-detection' as const,
|
||||
status: v.status as Video['status'],
|
||||
unique_defected_sign_board: v.summary?.unique_defected_sign_board,
|
||||
unique_pothole: v.summary?.unique_pothole,
|
||||
unique_road_crack: v.summary?.unique_road_crack,
|
||||
unique_damaged_road_marking: v.summary?.unique_damaged_road_marking,
|
||||
unique_good_sign_board: v.summary?.unique_good_sign_board,
|
||||
total_road_damage: v.summary?.total_road_damage,
|
||||
total_detections: v.summary?.total_detections,
|
||||
created_at: new Date().toISOString(),
|
||||
updated_at: new Date().toISOString(),
|
||||
}));
|
||||
},
|
||||
|
||||
/**
|
||||
* Upload a video for processing
|
||||
*/
|
||||
@@ -66,14 +22,6 @@ export const videoService = {
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get processing status of a video
|
||||
*/
|
||||
getVideoStatus: async (videoId: string): Promise<any> => {
|
||||
const response = await axiosClient.get(API_ROUTES.VIDEOS.STATUS(videoId));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get analysis results for a video
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user