Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 40 additions & 15 deletions packages/dashboard-app/src/components/charts.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,47 @@ export default function Charts() {
option: '1h'
})

const getFilteredTransactions = () => {
const getFilteredTransactions = async () => {
setIsFetchingTransactions(true)
setError(null)
getTimeSeries(filterData.period, {
startDate: filterData.from,
endDate: filterData.until
})
.then(timeSeries => {
setIsFetchingTransactions(false)
setTimeSeries(timeSeries)
})
.catch(err => {
console.error(err)
setError(err)
setIsFetchingTransactions(false)
})

const timeRanges = [
{ scale: TimeSeriesScale.minute, duration: { hours: 1 }, option: '1h' },
{ scale: TimeSeriesScale.day, duration: { days: 1 }, option: '1d' },
{ scale: TimeSeriesScale.day, duration: { weeks: 1 }, option: '1w' },
{ scale: TimeSeriesScale.day, duration: { months: 1 }, option: '1m' },
{ scale: TimeSeriesScale.day, duration: { years: 1 }, option: '1y' },
{ scale: TimeSeriesScale.day, duration: { years: 5 }, option: '5y' }
]

try {
for (const range of timeRanges) {
const data = await getTimeSeries(range.scale, {
startDate: sub(now, range.duration),
endDate: now
})
type BasicFilterOption = '1h' | '1d' | '1w' | '1m' | '1y' | '5y'; // Define this type if not already defined

if (data && data.length > 0) {
if (filterData.option !== range.option) {
setFilterData({
period: range.scale,
from: sub(now, range.duration),
until: now,
option: range.option as BasicFilterOption
})
}
setTimeSeries(data)
return
}
}
setTimeSeries([])
} catch (err) {
console.error(err)
setError(err)
} finally {
setIsFetchingTransactions(false)
}
}

React.useEffect(() => {
Expand All @@ -46,7 +71,7 @@ export default function Charts() {
const int = window.setInterval(getFilteredTransactions, 30000)

return () => window.clearInterval(int)
}, [filterData])
}, [])

if (error) {
return <ErrorMessage onRetry={getFilteredTransactions} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,20 +384,20 @@ const App: React.FC = () => {

const params = {
...(getFilters() as any),
filterLimit: 1000,
filterLimit: limit,
filterRepresentation: 'bulkrerun'
} satisfies BulkRunFilterCountParams[0]

getBulkRunFilterCount(params)
await getBulkRunFilterCount(params)
.then(res => {
hideBackdrop()

const message =
(!(startDate && endDate)
? ''
: 'No date range has been supplied, querying all transactions with the defined filters\n') +
`Your filters returned a total of ${res.count} transaction(s) that can be re-run`
const title = 'You have opted to do a Bulk Rerun!'
`Using filters this broad could rerun thousands of transactions`
const title = 'Confirm bulk rerun!'

showConfirmation(
message,
Expand All @@ -416,7 +416,7 @@ const App: React.FC = () => {
const params = {
...(getFilters() as any),
batchSize: event.batchSize,
filterLimit: 1000,
filterLimit: limit,
pauseQueue: event.paused
} satisfies BulkReRunParams[0]

Expand Down