-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6.6.0] Improvements for historic seasons
- Loading branch information
Showing
16 changed files
with
155 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
<?xml version='1.0' encoding='utf-8'?> | ||
<widget id="de.timodittmann.scd" version="6.5.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> | ||
<widget id="de.timodittmann.scd" version="6.6.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> | ||
<name>SC Dahenfeld</name> | ||
<description>An awesome SC Dahenfeld app.</description> | ||
<author email="[email protected]" href="http://timo-dittmann.de/">Timo Dittmann</author> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/app/dataproviders/soccer/ranking/historicRankingJson.model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export interface HistoricRankingJson { | ||
id: string; | ||
name: string; | ||
logo: string; | ||
matches: string; | ||
won: string; | ||
draw: string; | ||
lost: string; | ||
goalsFor: string; | ||
goalsAgainst: string; | ||
points: string; | ||
} |
44 changes: 44 additions & 0 deletions
44
src/app/dataproviders/soccer/ranking/historicRankingMapper.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { HistoricRankingMapper } from './historicRankingMapper'; | ||
import { HistoricRankingJson } from './historicRankingJson.model'; | ||
import { RankingTeam } from '../../../core/domain/rankingTeam.model'; | ||
|
||
describe('Mapper', () => { | ||
let mapper: HistoricRankingMapper; | ||
|
||
beforeEach(() => { | ||
mapper = new HistoricRankingMapper(); | ||
}); | ||
|
||
it('should handle null values for mapFrom', () => { | ||
expect(mapper.mapFrom(null)).toBe(null); | ||
}); | ||
|
||
it('should map from json to core model', () => { | ||
const actual: HistoricRankingJson = { | ||
id: '1', | ||
name: 'SC Dahenfeld', | ||
logo: '/images/scd.png', | ||
matches: '30', | ||
won: '29', | ||
draw: '1', | ||
lost: '0', | ||
goalsFor: '100', | ||
goalsAgainst: '12', | ||
points: '90', | ||
}; | ||
|
||
const expected: RankingTeam = new RankingTeam(); | ||
expected.id = 1; | ||
expected.name = 'SC Dahenfeld'; | ||
expected.image = '/images/scd.png'; | ||
expected.matches = 30; | ||
expected.wins = 29; | ||
expected.draws = 1; | ||
expected.losses = 0; | ||
expected.goalsFor = 100; | ||
expected.goalsAgainst = 12; | ||
expected.points = 90; | ||
|
||
expect(mapper.mapFrom(actual)).toEqual(expected); | ||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
src/app/dataproviders/soccer/ranking/historicRankingMapper.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { HistoricRankingJson } from './historicRankingJson.model'; | ||
import { RankingTeam } from '../../../core/domain/rankingTeam.model'; | ||
|
||
export class HistoricRankingMapper { | ||
mapFrom(param: HistoricRankingJson): RankingTeam { | ||
if (!param) { | ||
return null; | ||
} | ||
|
||
const rankingTeam = new RankingTeam(); | ||
rankingTeam.id = parseInt(param.id, 10); | ||
rankingTeam.name = param.name; | ||
rankingTeam.image = param.logo; | ||
rankingTeam.matches = parseInt(param.matches, 10); | ||
rankingTeam.wins = parseInt(param.won, 10); | ||
rankingTeam.draws = parseInt(param.draw, 10); | ||
rankingTeam.losses = parseInt(param.lost, 10); | ||
rankingTeam.goalsFor = parseInt(param.goalsFor, 10); | ||
rankingTeam.goalsAgainst = parseInt(param.goalsAgainst, 10); | ||
rankingTeam.points = parseInt(param.points, 10); | ||
return rankingTeam; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Observable } from 'rxjs'; | ||
import { environment } from '../../../../environments/environment'; | ||
import { map } from 'rxjs/operators'; | ||
import { Injectable } from '@angular/core'; | ||
import { HttpService } from '../../http.service'; | ||
import { HistoricRankingMapper } from './historicRankingMapper'; | ||
import { RankingTeam } from '../../../core/domain/rankingTeam.model'; | ||
import { HistoricRankingJson } from './historicRankingJson.model'; | ||
|
||
@Injectable() | ||
export class RankingService { | ||
private historicRankingMapper = new HistoricRankingMapper(); | ||
|
||
constructor(private httpService: HttpService) {} | ||
|
||
public loadHistoricRanking(projectId: number): Observable<RankingTeam[]> { | ||
return this.httpService | ||
.get<HistoricRankingJson[]>(environment.backendUrl + 'historicRanking?projectId=' + projectId) | ||
.pipe(map((ranking) => ranking.map(this.historicRankingMapper.mapFrom))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
src/app/presentation/pages/team-detail/ranking/team-detail-ranking.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters