-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
112 additions
and
19 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
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
16 changes: 16 additions & 0 deletions
16
projects/data/src/lib/stat-aggregators/clan-activity.service.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,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { ClanActivityService } from './clan-activity.service'; | ||
|
||
describe('ClanActivityService', () => { | ||
let service: ClanActivityService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(ClanActivityService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
projects/data/src/lib/stat-aggregators/clan-activity.service.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,32 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ActivityStats, MemberProfile, ClanMember } from 'bungie-models'; | ||
import { forkJoin, from, Observable } from 'rxjs'; | ||
import { map, mergeMap, toArray } from 'rxjs/operators'; | ||
import { ClanMemberRecentActivityService, ProfileService } from '../clan-db'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class ClanActivityService { | ||
readonly CONCURRENT_COUNT = 10; | ||
constructor(private profileService: ProfileService, private memberActivityService: ClanMemberRecentActivityService) {} | ||
|
||
getClanActivityStats(clanId: number, clanMemberProfiles: MemberProfile[]) { | ||
return from(clanMemberProfiles).pipe( | ||
mergeMap((member) => { | ||
return this.getMemberActivityStats(clanId, member); | ||
}, this.CONCURRENT_COUNT) | ||
); | ||
} | ||
|
||
private getMemberActivityStats(clanId: number, member: MemberProfile): Observable<ActivityStats> { | ||
return this.memberActivityService.getSerializedProfileActivity(clanId, member).pipe( | ||
map((memberActivityResponse) => { | ||
return { | ||
memberProfile: { profile: member.profile }, | ||
stats: memberActivityResponse | ||
}; | ||
}) | ||
); | ||
} | ||
} |
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