refactor: Update API calls in Dashboard component to use countOnly parameter for improved data handling and simplify response processing
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 5m50s
Publish Fast Tabler Docker image / build-and-push-fast (push) Successful in 5m50s
This commit is contained in:
@@ -80,9 +80,9 @@ function Dashboard() {
|
|||||||
try {
|
try {
|
||||||
// Загружаем данные с обработкой ошибок для каждого endpoint
|
// Загружаем данные с обработкой ошибок для каждого endpoint
|
||||||
const results = await Promise.allSettled([
|
const results = await Promise.allSettled([
|
||||||
axios.get('/api/domains-new', { params: { offset: 0, limit: 1 } }),
|
axios.get('/api/domains-new', { params: { countOnly: true } }),
|
||||||
axios.get('/api/ip-ranges', { params: { offset: 0, limit: 1 } }),
|
axios.get('/api/ip-ranges', { params: { countOnly: true } }),
|
||||||
axios.get('/api/asns', { params: { offset: 0, limit: 1 } }),
|
axios.get('/api/asns', { params: { countOnly: true } }),
|
||||||
axios.get('/api/servers'),
|
axios.get('/api/servers'),
|
||||||
axios.get('/api/servers/availability', { params: { ttlSeconds: 60 } }),
|
axios.get('/api/servers/availability', { params: { ttlSeconds: 60 } }),
|
||||||
axios.get('/api/s3/last-modified')
|
axios.get('/api/s3/last-modified')
|
||||||
@@ -97,15 +97,9 @@ function Dashboard() {
|
|||||||
const s3Res = results[5];
|
const s3Res = results[5];
|
||||||
|
|
||||||
// Получаем данные серверов для подсчета дополнительной статистики
|
// Получаем данные серверов для подсчета дополнительной статистики
|
||||||
const domains = domainsRes.status === 'fulfilled'
|
const domains = [];
|
||||||
? (Array.isArray(domainsRes.value.data?.items) ? domainsRes.value.data.items : domainsRes.value.data)
|
const ipRanges = [];
|
||||||
: [];
|
const asns = [];
|
||||||
const ipRanges = ipRangesRes.status === 'fulfilled'
|
|
||||||
? (Array.isArray(ipRangesRes.value.data?.items) ? ipRangesRes.value.data.items : ipRangesRes.value.data)
|
|
||||||
: [];
|
|
||||||
const asns = asnsRes.status === 'fulfilled'
|
|
||||||
? (Array.isArray(asnsRes.value.data?.items) ? asnsRes.value.data.items : asnsRes.value.data)
|
|
||||||
: [];
|
|
||||||
const servers = serversRes.status === 'fulfilled' ? serversRes.value.data : [];
|
const servers = serversRes.status === 'fulfilled' ? serversRes.value.data : [];
|
||||||
setRaw({ domains, ipRanges, asns, servers });
|
setRaw({ domains, ipRanges, asns, servers });
|
||||||
const countries = new Set(servers.map(server => server.country).filter(Boolean));
|
const countries = new Set(servers.map(server => server.country).filter(Boolean));
|
||||||
@@ -119,13 +113,13 @@ function Dashboard() {
|
|||||||
|
|
||||||
const domainsCount = domainsRes.status === 'fulfilled' && typeof domainsRes.value.data?.total === 'number'
|
const domainsCount = domainsRes.status === 'fulfilled' && typeof domainsRes.value.data?.total === 'number'
|
||||||
? domainsRes.value.data.total
|
? domainsRes.value.data.total
|
||||||
: domains.length;
|
: 0;
|
||||||
const ipRangesCount = ipRangesRes.status === 'fulfilled' && typeof ipRangesRes.value.data?.total === 'number'
|
const ipRangesCount = ipRangesRes.status === 'fulfilled' && typeof ipRangesRes.value.data?.total === 'number'
|
||||||
? ipRangesRes.value.data.total
|
? ipRangesRes.value.data.total
|
||||||
: ipRanges.length;
|
: 0;
|
||||||
const asnsCount = asnsRes.status === 'fulfilled' && typeof asnsRes.value.data?.total === 'number'
|
const asnsCount = asnsRes.status === 'fulfilled' && typeof asnsRes.value.data?.total === 'number'
|
||||||
? asnsRes.value.data.total
|
? asnsRes.value.data.total
|
||||||
: asns.length;
|
: 0;
|
||||||
|
|
||||||
setStats({
|
setStats({
|
||||||
domainsCount,
|
domainsCount,
|
||||||
|
|||||||
Reference in New Issue
Block a user