Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dify
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ai-tech
dify
Commits
ea36f95c
Commit
ea36f95c
authored
Jun 15, 2023
by
StyleZhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: dataset document list timer
parent
47703033
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
index.tsx
...ponents/base/notion-page-selector/page-selector/index.tsx
+4
-2
index.tsx
web/app/components/datasets/documents/index.tsx
+11
-9
No files found.
web/app/components/base/notion-page-selector/page-selector/index.tsx
View file @
ea36f95c
...
@@ -77,9 +77,10 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
...
@@ -77,9 +77,10 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
listMapWithChildrenAndDescendants
:
NotionPageTreeMap
listMapWithChildrenAndDescendants
:
NotionPageTreeMap
searchValue
:
string
searchValue
:
string
previewPageId
:
string
previewPageId
:
string
pagesMap
:
DataSourceNotionPageMap
}
>
)
=>
{
}
>
)
=>
{
const
{
t
}
=
useTranslation
()
const
{
t
}
=
useTranslation
()
const
{
dataList
,
handleToggle
,
checkedIds
,
handleCheck
,
canPreview
,
handlePreview
,
listMapWithChildrenAndDescendants
,
searchValue
,
previewPageId
}
=
data
const
{
dataList
,
handleToggle
,
checkedIds
,
handleCheck
,
canPreview
,
handlePreview
,
listMapWithChildrenAndDescendants
,
searchValue
,
previewPageId
,
pagesMap
}
=
data
const
current
=
dataList
[
index
]
const
current
=
dataList
[
index
]
const
currentWithChildrenAndDescendants
=
listMapWithChildrenAndDescendants
[
current
.
page_id
]
const
currentWithChildrenAndDescendants
=
listMapWithChildrenAndDescendants
[
current
.
page_id
]
const
hasChild
=
currentWithChildrenAndDescendants
.
descendants
.
size
>
0
const
hasChild
=
currentWithChildrenAndDescendants
.
descendants
.
size
>
0
...
@@ -96,7 +97,7 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
...
@@ -96,7 +97,7 @@ const Item = memo(({ index, style, data }: ListChildComponentProps<{
/>
/>
)
)
}
}
if
(
current
.
parent_id
===
'root'
)
{
if
(
current
.
parent_id
===
'root'
||
!
pagesMap
[
current
.
parent_id
]
)
{
return
(
return
(
<
div
></
div
>
<
div
></
div
>
)
)
...
@@ -287,6 +288,7 @@ const PageSelector = ({
...
@@ -287,6 +288,7 @@ const PageSelector = ({
listMapWithChildrenAndDescendants
,
listMapWithChildrenAndDescendants
,
searchValue
,
searchValue
,
previewPageId
:
currentPreviewPageId
,
previewPageId
:
currentPreviewPageId
,
pagesMap
,
}
}
}
}
>
>
{
Item
}
{
Item
}
...
...
web/app/components/datasets/documents/index.tsx
View file @
ea36f95c
...
@@ -93,19 +93,20 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
...
@@ -93,19 +93,20 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
datasetId
,
datasetId
,
params
:
query
,
params
:
query
,
},
apiParams
=>
fetchDocuments
(
omit
(
apiParams
,
'action'
)))
},
apiParams
=>
fetchDocuments
(
omit
(
apiParams
,
'action'
)))
const
{
data
:
datasetIndexingStatus
}
=
useSWR
(
timerCanRun
?
datasetId
:
null
,
getDatasetIndexingStatus
,
{
refreshInterval
:
2500
})
const
{
data
:
datasetIndexingStatus
,
mutate
:
mutateDatasetIndexingStatus
}
=
useSWR
(
timerCanRun
?
datasetId
:
null
,
getDatasetIndexingStatus
,
{
refreshInterval
:
2500
})
const
datasetDocumentProgress
:
[
Record
<
string
,
number
>
,
boolean
]
=
useMemo
(()
=>
{
const
datasetDocumentProgress
:
[
Record
<
string
,
number
>
,
boolean
]
=
useMemo
(()
=>
{
let
completedNum
=
0
let
completedNum
=
0
const
progressPercentMap
=
datasetIndexingStatus
?.
data
.
reduce
((
prev
:
Record
<
string
,
number
>
,
next
:
IndexingStatusResponse
)
=>
{
const
progressPercentMap
=
datasetIndexingStatus
?.
data
?
.
reduce
((
prev
:
Record
<
string
,
number
>
,
next
:
IndexingStatusResponse
)
=>
{
const
{
id
,
completed_segments
,
total_segments
,
indexing_status
}
=
next
const
{
id
,
completed_segments
,
total_segments
,
indexing_status
}
=
next
const
isEmbeddinged
=
indexing_status
===
'completed'
||
indexing_status
===
'paused'
||
indexing_status
===
'error'
if
(
i
ndexing_status
===
'completed'
||
indexing_status
===
'paused'
||
indexing_status
===
'error'
)
if
(
i
sEmbeddinged
)
completedNum
++
completedNum
++
const
completedCount
=
completed_segments
||
0
const
completedCount
=
completed_segments
||
0
const
totalCount
=
total_segments
||
0
const
totalCount
=
total_segments
||
0
if
(
totalCount
===
0
&&
completedCount
===
0
)
{
if
(
totalCount
===
0
&&
completedCount
===
0
)
{
prev
[
id
]
=
i
ndexing_status
===
'completed'
?
100
:
0
prev
[
id
]
=
i
sEmbeddinged
?
100
:
0
}
}
else
{
else
{
const
percent
=
Math
.
round
(
completedCount
*
100
/
totalCount
)
const
percent
=
Math
.
round
(
completedCount
*
100
/
totalCount
)
...
@@ -115,11 +116,11 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
...
@@ -115,11 +116,11 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
return
prev
return
prev
},
{})
||
{}
},
{})
||
{}
return
[
progressPercentMap
,
completedNum
===
datasetIndexingStatus
?.
data
.
length
]
if
(
completedNum
===
datasetIndexingStatus
?.
data
?.
length
)
},
[
datasetIndexingStatus
?.
data
]
)
setTimerCanRun
(
false
)
if
(
datasetDocumentProgress
[
1
])
return
[
progressPercentMap
,
completedNum
===
datasetIndexingStatus
?.
data
?.
length
]
setTimerCanRun
(
false
)
},
[
datasetIndexingStatus
]
)
const
documentsWithProgress
=
useMemo
(()
=>
{
const
documentsWithProgress
=
useMemo
(()
=>
{
return
{
return
{
...
@@ -187,8 +188,9 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
...
@@ -187,8 +188,9 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
body
:
params
,
body
:
params
,
})
})
mutate
()
mutate
()
setNotionPageSelectorModalVisible
(
false
)
setTimerCanRun
(
true
)
setTimerCanRun
(
true
)
mutateDatasetIndexingStatus
(
undefined
,
{
revalidate
:
true
})
setNotionPageSelectorModalVisible
(
false
)
}
}
const
handleSync
=
async
()
=>
{
const
handleSync
=
async
()
=>
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment