Skip to content

Commit

Permalink
Merge pull request #44 from tronghieuvuong/tvuong/teamsMetrics
Browse files Browse the repository at this point in the history
GraphQL Query and Frontend changes
  • Loading branch information
tronghieuvuong authored Dec 6, 2023
2 parents eba25cf + 89bfb0f commit 1ed6063
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 100 deletions.
1 change: 1 addition & 0 deletions apps/application-status/composables/getReleases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export async function getReleases (
totalCount
nodes {
closedAt
title
issues {
totalCount
}
Expand Down
3 changes: 3 additions & 0 deletions apps/application-status/composables/getSprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ export async function getSprint (
state
totalPoints
updatedAt
issues {
totalCount
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion apps/application-status/composables/getWorkFlows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ async function waitForSuccessStatus (
console.log('status' + status)
if (status === 'completed') {
const issues = await getIssue(owner, repo, teamName)
return issues
return issues.body
}

// Wait for a specified delay before checking again
Expand Down
61 changes: 61 additions & 0 deletions apps/application-status/data/TeamsData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { Sprint } from '~/interface/interfaces'
import BoardName from '~/enums/boardName'
import BoardTitles from '~/enums/boardTitles'
const sprint: Sprint = {
closedIssuesCount: 0,
completedPoints: 0,
createdAt: '',
description: '',
endAt: '',
id: '',
name: '',
startAt: '',
state: '',
totalPoints: 0,
updatedAt: '',
numberOfRelease: 0,
issues: {
totalCount: 0
}
}
const result = {
totalReleases: 0,
totalIssues: 0,
totalBugs: 0
}
const teams = [
{
id: 1,
title: BoardTitles.ENTITIES,
board: BoardName.ENTITIES,
keyWord: 'enti',
result,
sprint
},
{
id: 2,
title: BoardTitles.NAMESTEAMSPACE,
board: BoardName.NAMETEAMSPACE,
keyWord: 'name',
result,
sprint
},
{
id: 3,
title: BoardTitles.ASSETS,
board: BoardName.ASSETS,
keyWord: 'assets',
result,
sprint
},
{
id: 4,
title: BoardTitles.RELATIONSHIPS,
board: BoardName.RELATIONSHIPS,
keyWord: 'relationships',
result,
sprint
}
]

export default teams
2 changes: 2 additions & 0 deletions apps/application-status/enums/boardName.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
enum BoardName {
ENTITIES = 'entities-team-space-2023',
NAMETEAMSPACE = 'names-team-board',
ASSETS = 'Assets Team Space',
RELATIONSHIPS = 'Relationships Team Space'
}

export default BoardName
8 changes: 8 additions & 0 deletions apps/application-status/enums/boardTitles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum BoardTitles {
ENTITIES = 'ENTITIES',
NAMESTEAMSPACE = 'NAMES TEAM SPACE',
ASSETS = 'ASSETS',
RELATIONSHIPS = 'RELATIONSHIPS'
}

export default BoardTitles
6 changes: 4 additions & 2 deletions apps/application-status/helper/castingResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export function castingSprint (sprint: any, noReleases: any) {
state: sprint.state,
totalPoints: sprint.totalPoints,
updatedAt: sprint.updatedAt,
numberOfRelease: noReleases
numberOfRelease: noReleases,
issues: sprint.issues
}
return res
}
Expand All @@ -24,7 +25,8 @@ export function castingReleases (releases: any) {
const release = releases[i]
res.push({
closeAt: release.closeAt,
issues: release.issues.totalCount
issues: release.issues.totalCount,
title: release.title
})
}
return res
Expand Down
13 changes: 11 additions & 2 deletions apps/application-status/helper/filterRelease.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
function filterReleases (releases: any, startAt: any, endAt: any) {
import { Release } from '~/interface/interfaces'
export function filterReleasesByDate (releases: any, startAt: any, endAt: any) {
const releasesWithinDateRange =
releases.nodes.filter((release: any) => {
const closedAt = new Date(release.closedAt)
Expand All @@ -10,4 +11,12 @@ function filterReleases (releases: any, startAt: any, endAt: any) {
return releasesWithinDateRange
}

export default filterReleases
export function filterReleaseByTeam (releases: Release[], team: string) {
console.log(releases)
const releaseHasName = releases.filter((release: Release) => {
const title = release.title
return title.toLowerCase().includes(team)
})
console.log(releaseHasName)
return releaseHasName
}
11 changes: 5 additions & 6 deletions apps/application-status/helper/getData.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import filterReleases from './filterRelease'
import { filterReleasesByDate, filterReleaseByTeam } from './filterRelease'
import { castingReleases, castingSprint } from './castingResponse'
import { Response } from '~/interface/interfaces'
import { getSprint } from '~/composables/getSprint'
import { getReleases } from '~/composables/getReleases'

export default async function getData (boardID: any) {
export default async function getData (boardID: any, team: string, releases: any) {
const sprint = await getSprint(boardID)
const releases = await getReleases(boardID)
const releasesInRange = filterReleases(
const releasesInRange = filterReleasesByDate(
releases,
sprint.startAt,
sprint.endAt
)
const castedSprint = castingSprint(sprint, releasesInRange.length)
const castedReleases = castingReleases(releasesInRange)
const releaseInTeam = filterReleaseByTeam(castedReleases, team)
const res: Response = {
sprint: castedSprint,
releases: castedReleases
releases: releaseInTeam
}
return res
}
4 changes: 4 additions & 0 deletions apps/application-status/interface/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export interface Release {
title: string
closeAt: string
issues: number
}
Expand All @@ -16,6 +17,9 @@ export interface Sprint {
totalPoints: number
updatedAt: string
numberOfRelease: number
issues: {
totalCount: number
}
}

export interface Response {
Expand Down
147 changes: 58 additions & 89 deletions apps/application-status/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,100 +2,60 @@
<div>
<navbar />
<div class="metrics flex flex-col self-center">
<div>
<b class="text-3xl">{{ entities.sprint.name }}</b>
</div>
<br>
<div>
<b class="text-2xl">ENTITIES REPO</b>
</div>
<div>
<h2 class="text-xl">
Total Points
</h2>
<pre>{{ entities.sprint.totalPoints }}</pre>
</div>
<div>
<h2 class="text-xl">
Total closed releases
</h2>
<pre>{{ entities.sprint.numberOfRelease }}</pre>
</div>
<div>
<h2 class="text-xl">
Total Issues
</h2>
<pre>{{ calculateTotalIssue(entities) }}</pre>
</div>
<br>
<div>
<b class="text-2xl">NAME TEAM REPO</b>
</div>
<div>
<h2 class="text-xl">
Total Points
</h2>
<pre>{{ nameteam.sprint.totalPoints }}</pre>
</div>
<div>
<h2 class="text-xl">
Total closed releases
</h2>
<pre>{{ nameteam.sprint.numberOfRelease }}</pre>
</div>
<div>
<h2 class="text-xl">
Total Issues
</h2>
<pre>{{ calculateTotalIssue(nameteam) }}</pre>
</div>
<ul>
<li v-for="team in teams" :key="team.id">
<div>
<b class="text-2xl">{{ team.title }}</b>
</div>
<div>
<b class="text-2xl">{{ team.sprint.name }}</b>
</div>
<div>
<h2 class="text-xl">
Total Points
</h2>
<pre>{{ team.sprint.totalPoints }}</pre>
</div>
<div>
<h2 class="text-xl">
Total closed releases
</h2>
<pre>{{ team.result.totalReleases }}</pre>
</div>
<div>
<h2 class="text-xl">
Total Issues
</h2>
<pre>{{ team.sprint.issues.totalCount }}</pre>
</div>
<br>
</li>
</ul>
</div>
<pre class="mx-20">
<div v-if="issues === null">
Loading issues
</div>
{{ issues }}
</pre>
</div>
</template>

<script lang="ts">
import getData from '../helper/getData'
import BoardName from '../enums/boardName'
import { Response, Sprint } from '../interface/interfaces'
import { Release } from '../interface/interfaces'
import { getBoard } from '../composables/getBoard'
import workflowRun from '../enums/workflowRun'
import runWorkFlow from '../composables/runWorkFlow'
import runJob from '../enums/runJob'
import waitForSuccessStatus from '../composables/getWorkFlows'
// import workflowRun from '../enums/workflowRun'
// import runWorkFlow from '../composables/runWorkFlow'
// import runJob from '../enums/runJob'
// import waitForSuccessStatus from '../composables/getWorkFlows'
import teams from '../data/TeamsData'
export default {
data () {
const id = 1
const sprint: Sprint = {
closedIssuesCount: 0,
completedPoints: 0,
createdAt: '',
description: '',
endAt: '',
id: '',
name: '',
startAt: '',
state: '',
totalPoints: 0,
updatedAt: '',
numberOfRelease: 0
}
const entities: Response = {
sprint,
releases: []
}
const nameteam: Response = {
sprint,
releases: []
}
const issues: any = null
return {
id,
entities,
nameteam,
teams,
issues
}
},
Expand All @@ -105,18 +65,27 @@ export default {
methods: {
async getContent () {
const entities = await getBoard(BoardName.ENTITIES)
const nameteam = await getBoard(BoardName.NAMETEAMSPACE)
this.entities = await getData(entities)
this.nameteam = await getData(nameteam)
await runWorkFlow(workflowRun.OWNER, workflowRun.REPO, runJob.ENTITIES)
this.issues = await waitForSuccessStatus(workflowRun.OWNER, workflowRun.REPO, runJob.ENTITIES, 'Entity')
console.log(this.issues)
// this.assets = await getData(entities, 'assets', releases)
// await runWorkFlow(workflowRun.OWNER, workflowRun.REPO, runJob.ENTITIES)
// this.issues = await waitForSuccessStatus(workflowRun.OWNER, workflowRun.REPO, runJob.ENTITIES, 'Entity')
for (let i = 0; i < this.teams.length; i++) {
const team = this.teams[i]
const boardID = await getBoard(team.board)
team.id = boardID
const releases = await getReleases(boardID)
const teamsContent = await getData(boardID, team.keyWord, releases)
team.sprint = teamsContent.sprint
team.result = {
totalIssues: this.calculateTotalIssue(teamsContent.releases),
totalReleases: teamsContent.releases.length,
totalBugs: 0
}
}
},
calculateTotalIssue (data: Response) {
calculateTotalIssue (releases: Release[]) {
let sum = 0
for (let i = 0; i < data.releases.length; i++) {
sum += data.releases[i].issues
for (let i = 0; i < releases.length; i++) {
sum += releases[i].issues
}
return sum
}
Expand Down

0 comments on commit 1ed6063

Please sign in to comment.