feat: refactor metrics (#2861)

This commit is contained in:
Alex Inkin
2025-04-01 00:22:54 +04:00
committed by GitHub
parent 1883c9666e
commit f51dcf23d6
12 changed files with 395 additions and 248 deletions

View File

@@ -123,6 +123,10 @@ export class MockApiService extends ApiService {
return from(this.initProgress()).pipe(
startWith(PROGRESS),
) as WebSocketSubject<T>
} else if (guid === 'metrics-guid') {
return interval(1000).pipe(
map(() => Mock.getMetrics()),
) as WebSocketSubject<T>
} else {
throw new Error('invalid guid type')
}
@@ -358,7 +362,7 @@ export class MockApiService extends ApiService {
): Promise<RR.FollowServerMetricsRes> {
await pauseFor(2000)
return {
guid: 'iqudh37um-i38u3-34-a51b-jkhd783ein',
guid: 'metrics-guid',
metrics: Mock.getMetrics(),
}
}

View File

@@ -1,14 +1,6 @@
import { inject, Injectable } from '@angular/core'
import { PatchDB } from 'patch-db-client'
import {
combineLatest,
defer,
map,
shareReplay,
startWith,
switchMap,
timer,
} from 'rxjs'
import { combineLatest, defer, map, shareReplay, switchMap, timer } from 'rxjs'
import { ApiService } from 'src/app/services/api/embassy-api.service'
import { DataModel } from 'src/app/services/patch-db/data-model'
@@ -44,9 +36,7 @@ export class TimeService {
const hoursSec = uptime % (60 * 60)
const minutes = Math.floor(hoursSec / 60)
const seconds = uptime % 60
return `${days}:${hours}:${minutes}:${seconds}`
return { days, hours, minutes, seconds }
}),
startWith('-:-:-:-'),
)
}