Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
upgrade-data-crawler-fe
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
ThinhNC
upgrade-data-crawler-fe
Commits
084ac012
Commit
084ac012
authored
Oct 17, 2026
by
ThinhNC
Browse files
Options
Browse Files
Download
Plain Diff
Merge develop into staging: auto-poll progress bar in RecentJobsWidget
parents
c6ed1d90
78d89caa
Pipeline
#53750
passed with stage
in 1 minute and 23 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
2 deletions
+20
-2
use-crawl-jobs.ts
src/hooks/use-crawl-jobs.ts
+20
-2
No files found.
src/hooks/use-crawl-jobs.ts
View file @
084ac012
...
...
@@ -22,14 +22,32 @@ export const CRAWL_JOBS_QUERY_KEYS = {
};
/**
*
Hook lấy danh sách Crawl Jobs hỗ trợ Server-side Pagination, Sorting và Filter
*
Statuses coi là "đang hoạt động" → trigger polling tự động
*/
export
function
useCrawlJobs
(
query
?:
CrawlJobQueryDto
)
{
const
ACTIVE_STATUSES
:
CrawlJob
[
"status"
][]
=
[
"RUNNING"
,
"PROCESSING_EXPORT"
,
"PENDING"
,
"QUEUED"
];
/**
* Hook lấy danh sách Crawl Jobs hỗ trợ Server-side Pagination, Sorting và Filter.
* Tự động poll mỗi 4 giây khi có job đang chạy, dừng polling khi tất cả hoàn thành.
*/
export
function
useCrawlJobs
(
query
?:
CrawlJobQueryDto
,
options
?:
{
refetchInterval
?:
number
|
false
}
)
{
return
useQuery
({
queryKey
:
CRAWL_JOBS_QUERY_KEYS
.
list
(
query
),
queryFn
:
()
=>
crawlJobService
.
getJobs
(
query
),
placeholderData
:
(
previousData
)
=>
previousData
,
staleTime
:
5000
,
// Tự động poll mỗi 4s khi có job đang chạy, dừng khi tất cả xong.
// Caller có thể override bằng options.refetchInterval
refetchInterval
:
options
?.
refetchInterval
!==
undefined
?
options
.
refetchInterval
:
(
q
)
=>
{
const
data
=
q
.
state
.
data
as
{
items
?:
CrawlJob
[]
}
|
undefined
;
const
hasActive
=
data
?.
items
?.
some
((
j
)
=>
ACTIVE_STATUSES
.
includes
(
j
.
status
));
return
hasActive
?
4000
:
false
;
},
});
}
...
...
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