@@ -20,9 +20,10 @@ import { useWebsocket } from "@/submodules/react-components/hooks/web-socket/use
2020import { getAllComments } from "@/src/services/base/comment" ;
2121import { getAttributes } from "@/src/services/base/attribute" ;
2222import { getInformationSourcesOverviewData } from "@/src/services/base/heuristic" ;
23- import { getLabelingTasksByProjectId } from "@/src/services/base/project" ;
23+ import { getLabelingTasksByProjectId , getProjectTokenization } from "@/src/services/base/project" ;
2424import { getEmbeddings } from "@/src/services/base/embedding" ;
2525import { Application , CurrentPage } from "@/submodules/react-components/hooks/web-socket/constants" ;
26+ import { timer } from "rxjs" ;
2627
2728export function HeuristicsOverview ( ) {
2829 const dispatch = useDispatch ( ) ;
@@ -33,12 +34,15 @@ export function HeuristicsOverview() {
3334 const attributes = useSelector ( selectUsableNonTextAttributes ) ;
3435 const allUsers = useSelector ( selectAllUsers ) ;
3536 const [ filteredList , setFilteredList ] = useState ( [ ] ) ;
37+ const [ tokenizationProgress , setTokenizationProgress ] = useState ( null ) ;
38+
3639
3740 useEffect ( ( ) => {
3841 if ( ! projectId || ! embeddings || ! attributes ) return ;
3942 refetchLabelingTasksAndProcess ( ) ;
4043 refetchHeuristicsAndProcess ( ) ;
4144 refetchEmbeddingsAndProcess ( ) ;
45+ checkProjectTokenization ( ) ;
4246 if ( attributes . length == 0 ) {
4347 getAttributes ( projectId , [ 'ALL' ] , ( res ) => {
4448 dispatch ( setAllAttributes ( res . data [ 'attributesByProjectId' ] ) ) ;
@@ -91,6 +95,12 @@ export function HeuristicsOverview() {
9195 } ) ;
9296 }
9397
98+ function checkProjectTokenization ( ) {
99+ getProjectTokenization ( projectId , ( res ) => {
100+ setTokenizationProgress ( res . data [ 'projectTokenization' ] ?. progress ) ;
101+ } ) ;
102+ }
103+
94104 const handleWebsocketNotification = useCallback ( ( msgParts : string [ ] ) => {
95105 if ( [ 'labeling_task_updated' , 'labeling_task_created' ] . includes ( msgParts [ 1 ] ) ) {
96106 refetchLabelingTasksAndProcess ( ) ;
@@ -102,14 +112,25 @@ export function HeuristicsOverview() {
102112 } else if ( msgParts [ 1 ] == 'embedding_deleted' || ( msgParts [ 1 ] == 'embedding' && msgParts [ 3 ] == 'state' ) ) {
103113 refetchEmbeddingsAndProcess ( ) ;
104114 }
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+ }
105126 } , [ projectId ] ) ;
106127
107128 const orgId = useSelector ( selectOrganizationId ) ;
108129 useWebsocket ( orgId , Application . REFINERY , CurrentPage . HEURISTICS , handleWebsocketNotification , projectId ) ;
109130
110131 return ( projectId && < div className = "p-4 bg-gray-100 h-full flex-1 flex flex-col" >
111132 < div className = "w-full h-full -mr-4" >
112- < HeuristicsHeader refetch = { refetchHeuristicsAndProcess }
133+ < HeuristicsHeader refetch = { refetchHeuristicsAndProcess } tokenizationProgress = { tokenizationProgress }
113134 filterList = { ( labelingTask : LabelingTask ) => setFilteredList ( labelingTask != null ? heuristics . filter ( ( heuristic ) => heuristic . labelingTaskId === labelingTask . id ) : heuristics ) } />
114135
115136 { heuristics && heuristics . length == 0 ? (
0 commit comments