Skip to content

Commit 00ba041

Browse files
move getPassRate function to testRun service
1 parent dac07a3 commit 00ba041

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/app/pages/project/project-view/project-veiw.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class ProjectViewComponent implements OnInit {
7171

7272
getNumberOfFails(id: number) {
7373
const stats: TestRunStat = this.testRunStats.filter(x => x.id === id)[0];
74-
return stats ? ((stats.passed / stats.total) * 100).toFixed(2) : 0;
74+
return this.testrunService.getPassRate(stats);
7575
}
7676

7777
openTestRun(testRunId: number) {

src/app/pages/project/testrun/testrun-list/testruns.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export class TestRunsComponent implements OnInit {
6666
run['duration'] = new Date(run.finish_time).getTime() - new Date(run.start_time).getTime();
6767
run['totalTests'] = (this.testRunStats.find(stat => stat.id === run.id) || { 'total': 0 }).total;
6868
run['not_assigned'] = (this.testRunStats.find(stat => stat.id === run.id) || { 'not_assigned': 0 }).not_assigned;
69-
run['passrate'] = this.getPassRate(this.testRunStats.find(stat => stat.id === run.id) || new TestRunStat());
69+
run['passrate'] = this.testrunService.getPassRate(this.testRunStats.find(stat => stat.id === run.id) || new TestRunStat());
7070
}
7171
});
7272
this.tbCols = [
@@ -187,10 +187,6 @@ export class TestRunsComponent implements OnInit {
187187
this.hideModal = $event;
188188
}
189189

190-
getPassRate(stat: TestRunStat) {
191-
return stat ? ((stat.passed / stat.total) * 100).toFixed(2) : 0;
192-
}
193-
194190
uploadResults() {
195191
const columns = [
196192
{ name: 'Test Run ID', property: 'test_run_id' },

src/app/services/testRun.service.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,8 @@ export class TestRunService extends SimpleRequester {
6060
const seconds = duration - (hours * 3600 + minutes * 60);
6161
return hours + 'h:' + minutes + 'm:' + seconds + 's';
6262
}
63+
64+
getPassRate(stat: TestRunStat): string | number {
65+
return stat ? ((stat.passed / stat.total) * 100).toFixed(2) : 0;
66+
}
6367
}

0 commit comments

Comments
 (0)