Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Chetan11-dev authored and Noutbuk committed Apr 3, 2024
1 parent 05bf57a commit f838417
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 3 additions & 2 deletions frontend/src/components/OutputComponent/OutputComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
import Link from 'next/link'
import { useEffect, useState } from 'react'
import Api from '../../utils/api'
import { TaskStatus, filterIsDoingTasks, isDoing } from '../../utils/models'
import { TaskStatus, filterAndMapAllTasks, filterIsDoingTasks, isDoing } from '../../utils/models'
import { EmptyOutputs, EmptyScraper } from '../Empty/Empty'
import Toast from '../../utils/cogo-toast'
import ClickOutside from '../ClickOutside/ClickOutside'
Expand Down Expand Up @@ -338,7 +338,8 @@ const OutputComponent = ({ scrapers, tasks: taskResponse }) => {
const isCleared = { isCleared: false }; // Initialize as an object with isCleared property
const intervalId = setInterval(async () => {
if (!isCleared.isCleared) { // Access the isCleared property
const response = await Api.isAnyTaskFinished(pendingTaskIds)
const all_tasks = filterAndMapAllTasks(results)
const response = await Api.isAnyTaskFinished(pendingTaskIds, all_tasks)
if (response.data.result && !isCleared.isCleared) {
const { data } = await Api.getTasks(active_page)
if (!isCleared.isCleared) { // Access the isCleared property
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/utils/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ function getTasks(page=1, per_page=100) {
})
}

function isAnyTaskFinished(task_ids) {
function isAnyTaskFinished(task_ids, all_tasks) {
return AxiosInstance.post(`/tasks/is-any-task-finished`, {
task_ids: task_ids,
all_tasks: all_tasks
}, {
silent: true,
silenceError:true,
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/utils/models.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ export function isDoing(task) {

export function filterIsDoingTasks(tasks: any[]) {
return tasks.filter(isDoing)
}


export function filterAndMapAllTasks(tasks: any[]) {
return tasks.filter(x=> x.is_all_task === true && isDoing(x) ).map(x=> ({id: x.id, result_count: x.result_count}))
}

0 comments on commit f838417

Please sign in to comment.