Browse Source

Update repository and application service

pull/1679/head
Hironsan 2 years ago
parent
commit
6fad45af7a
4 changed files with 20 additions and 3 deletions
  1. 6
      frontend/domain/models/metrics/metrics.ts
  2. 3
      frontend/domain/models/metrics/metricsRepository.ts
  3. 8
      frontend/repositories/metrics/apiMetricsRepository.ts
  4. 6
      frontend/services/application/metrics/metricsApplicationService.ts

6
frontend/domain/models/metrics/metrics.ts

@ -6,3 +6,9 @@ export interface Progress {
total: number
progress: {user: string, done: number}[]
}
export interface MyProgress {
total: number
complete: number
remaining: number
}

3
frontend/domain/models/metrics/metricsRepository.ts

@ -1,7 +1,8 @@
import { Distribution, Progress } from '~/domain/models/metrics/metrics'
import { Distribution, Progress, MyProgress } from '~/domain/models/metrics/metrics'
export interface MetricsRepository {
fetchCategoryDistribution(projectId: string): Promise<Distribution>
fetchSpanDistribution(projectId: string): Promise<Distribution>
fetchMemberProgress(projectId: string): Promise<Progress>
fetchMyProgress(projectId: string): Promise<MyProgress>
}

8
frontend/repositories/metrics/apiMetricsRepository.ts

@ -1,6 +1,6 @@
import ApiService from '@/services/api.service'
import { MetricsRepository } from '@/domain/models/metrics/metricsRepository'
import { Distribution, Progress } from '~/domain/models/metrics/metrics'
import { Distribution, Progress, MyProgress } from '~/domain/models/metrics/metrics'
export class APIMetricsRepository implements MetricsRepository {
constructor(
@ -24,4 +24,10 @@ export class APIMetricsRepository implements MetricsRepository {
const response = await this.request.get(url)
return response.data
}
async fetchMyProgress(projectId: string): Promise<MyProgress> {
const url = `/projects/${projectId}/metrics/progress`
const response = await this.request.get(url)
return response.data
}
}

6
frontend/services/application/metrics/metricsApplicationService.ts

@ -1,5 +1,5 @@
import { MetricsRepository } from '~/domain/models/metrics/metricsRepository'
import { Progress, Distribution } from '~/domain/models/metrics/metrics'
import { Progress, Distribution, MyProgress } from '~/domain/models/metrics/metrics'
export class MetricsApplicationService {
constructor(
@ -17,4 +17,8 @@ export class MetricsApplicationService {
public async fetchSpanDistribution(projectId: string): Promise<Distribution> {
return await this.repository.fetchSpanDistribution(projectId)
}
public async fetchMyProgress(projectId: string): Promise<MyProgress> {
return await this.repository.fetchMyProgress(projectId)
}
}
Loading…
Cancel
Save