@@ -20,9 +20,10 @@ import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/use
20
20
import { getAllComments } from "@/src/services/base/comment" ;
21
21
import { getAttributes } from "@/src/services/base/attribute" ;
22
22
import { getInformationSourcesOverviewData } from "@/src/services/base/heuristic" ;
23
- import { getLabelingTasksByProjectId } from "@/src/services/base/project" ;
23
+ import { getLabelingTasksByProjectId , getProjectTokenization } from "@/src/services/base/project" ;
24
24
import { getEmbeddings } from "@/src/services/base/embedding" ;
25
25
import { Application , CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants" ;
26
+ import { timer } from "rxjs" ;
26
27
27
28
export function HeuristicsOverview ( ) {
28
29
const dispatch = useDispatch ( ) ;
@@ -33,12 +34,15 @@ export function HeuristicsOverview() {
33
34
const attributes = useSelector ( selectUsableNonTextAttributes ) ;
34
35
const allUsers = useSelector ( selectAllUsers ) ;
35
36
const [ filteredList , setFilteredList ] = useState ( [ ] ) ;
37
+ const [ tokenizationProgress , setTokenizationProgress ] = useState ( null ) ;
38
+
36
39
37
40
useEffect ( ( ) => {
38
41
if ( ! projectId || ! embeddings || ! attributes ) return ;
39
42
refetchLabelingTasksAndProcess ( ) ;
40
43
refetchHeuristicsAndProcess ( ) ;
41
44
refetchEmbeddingsAndProcess ( ) ;
45
+ checkProjectTokenization ( ) ;
42
46
if ( attributes . length == 0 ) {
43
47
getAttributes ( projectId , [ 'ALL' ] , ( res ) => {
44
48
dispatch ( setAllAttributes ( res . data [ 'attributesByProjectId' ] ) ) ;
@@ -91,6 +95,12 @@ export function HeuristicsOverview() {
91
95
} ) ;
92
96
}
93
97
98
+ function checkProjectTokenization ( ) {
99
+ getProjectTokenization ( projectId , ( res ) => {
100
+ setTokenizationProgress ( res . data [ 'projectTokenization' ] ?. progress ) ;
101
+ } ) ;
102
+ }
103
+
94
104
const handleWebsocketNotification = useCallback ( ( msgParts : string [ ] ) => {
95
105
if ( [ 'labeling_task_updated' , 'labeling_task_created' ] . includes ( msgParts [ 1 ] ) ) {
96
106
refetchLabelingTasksAndProcess ( ) ;
@@ -102,14 +112,25 @@ export function HeuristicsOverview() {
102
112
} else if ( msgParts [ 1 ] == 'embedding_deleted' || ( msgParts [ 1 ] == 'embedding' && msgParts [ 3 ] == 'state' ) ) {
103
113
refetchEmbeddingsAndProcess ( ) ;
104
114
}
115
+
116
+ if ( msgParts [ 1 ] == 'tokenization' ) {
117
+ if ( msgParts [ 3 ] == 'progress' ) {
118
+ setTokenizationProgress ( Number ( msgParts [ 4 ] ) ) ;
119
+ } else if ( msgParts [ 3 ] == 'state' ) {
120
+ if ( msgParts [ 4 ] == 'IN_PROGRESS' ) setTokenizationProgress ( 0 ) ;
121
+ else if ( msgParts [ 4 ] == 'FINISHED' ) {
122
+ timer ( 5000 ) . subscribe ( ( ) => checkProjectTokenization ( ) ) ;
123
+ }
124
+ }
125
+ }
105
126
} , [ projectId ] ) ;
106
127
107
128
const orgId = useSelector ( selectOrganizationId ) ;
108
129
useWebsocket ( orgId , Application . REFINERY , CurrentPage . HEURISTICS , handleWebsocketNotification , projectId ) ;
109
130
110
131
return ( projectId && < div className = "p-4 bg-gray-100 h-full flex-1 flex flex-col" >
111
132
< div className = "w-full h-full -mr-4" >
112
- < HeuristicsHeader refetch = { refetchHeuristicsAndProcess }
133
+ < HeuristicsHeader refetch = { refetchHeuristicsAndProcess } tokenizationProgress = { tokenizationProgress }
113
134
filterList = { ( labelingTask : LabelingTask ) => setFilteredList ( labelingTask != null ? heuristics . filter ( ( heuristic ) => heuristic . labelingTaskId === labelingTask . id ) : heuristics ) } />
114
135
115
136
{ heuristics && heuristics . length == 0 ? (
0 commit comments