@@ -2,20 +2,47 @@ import api, { handleApiError } from "@/utils/api";
2
2
3
3
type IndexingStatusResponse = boolean | { detail : string } ;
4
4
5
+ export interface DocIndexingTask {
6
+ error_trace : string ;
7
+ finished_datetime_utc : string ;
8
+ upload_id : string ;
9
+ user_id : number ;
10
+ workspace_id : number ;
11
+ parent_file_name : string ;
12
+ created_datetime_utc : string ;
13
+ task_id : string ;
14
+ doc_name : string ;
15
+ task_status : string ;
16
+ }
17
+
5
18
export interface DocIndexingStatusRow {
6
19
fileName : string ;
7
20
status : "Ongoing" | "Done" | "Error" ;
8
21
docsIndexed : string ;
9
22
errorTrace : string ;
10
23
created_at : string ;
11
24
finished_at : string ;
25
+ tasks : DocIndexingTask [ ] ;
12
26
}
13
27
14
28
interface ContentBody {
15
29
content_title : string ;
16
30
content_text : string ;
17
31
content_metadata : Record < string , unknown > ;
18
32
}
33
+
34
+ const formatDate = ( dateString : string ) => {
35
+ if ( ! dateString ) return "—" ;
36
+ const date = new Date ( dateString ) ;
37
+ return new Intl . DateTimeFormat ( "en-US" , {
38
+ year : "numeric" ,
39
+ month : "short" ,
40
+ day : "numeric" ,
41
+ hour : "2-digit" ,
42
+ minute : "2-digit" ,
43
+ second : "2-digit" ,
44
+ } ) . format ( date ) ;
45
+ } ;
19
46
const getContentList = async ( {
20
47
token,
21
48
skip = 0 ,
@@ -208,19 +235,6 @@ const getDocIndexingStatusData = async (
208
235
headers : { Authorization : `Bearer ${ token } ` } ,
209
236
} ) ;
210
237
211
- const formatDate = ( dateString : string ) => {
212
- if ( ! dateString ) return "—" ;
213
- const date = new Date ( dateString ) ;
214
- return new Intl . DateTimeFormat ( "en-US" , {
215
- year : "numeric" ,
216
- month : "short" ,
217
- day : "numeric" ,
218
- hour : "2-digit" ,
219
- minute : "2-digit" ,
220
- second : "2-digit" ,
221
- } ) . format ( date ) ;
222
- } ;
223
-
224
238
return response . data
225
239
. map ( ( entry : any ) => ( {
226
240
fileName : entry . parent_file_name ,
@@ -234,6 +248,7 @@ const getDocIndexingStatusData = async (
234
248
errorTrace : entry . error_trace || "" ,
235
249
created_at : formatDate ( entry . created_datetime_utc ) ,
236
250
finished_at : formatDate ( entry . finished_datetime_utc ) ,
251
+ tasks : ( entry . tasks as DocIndexingTask [ ] ) || [ ] ,
237
252
} ) )
238
253
. sort (
239
254
( a : DocIndexingStatusRow , b : DocIndexingStatusRow ) =>
@@ -246,6 +261,7 @@ const getDocIndexingStatusData = async (
246
261
} ;
247
262
248
263
export {
264
+ formatDate ,
249
265
getContentList ,
250
266
getContent ,
251
267
archiveContent ,
0 commit comments