Skip to content

Commit

Permalink
Stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
WorthyD committed Dec 6, 2020
1 parent 919701d commit 50128c8
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 19 deletions.
1 change: 1 addition & 0 deletions debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
[1204/164147.801:ERROR:process_info.cc(329)] VirtualQueryEx: Access is denied. (0x5)
[1204/164147.801:ERROR:process_info.cc(556)] ReadMemoryInfo failed
[1204/164147.801:ERROR:scoped_process_suspend.cc(40)] NtResumeProcess: An attempt was made to access an exiting process. (0xc000010a)
[1205/195708.258:ERROR:directory_reader_win.cc(43)] FindFirstFile: The system cannot find the path specified. (0x3)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { SECONDS_IN_WEEK, SECONDS_IN_DAY } from '@destiny/models/constants';
import { formatDate } from 'projects/data/src/lib/utility/format-date';
export const MOCK_ROSTER_ACTIVITY = [];
export const MOCK_ROSTER_ACTIVITIES = [];
export const MOCK_ROSTER_ACTIVITIES_COMBINE = [];
const stats = [];

const today = new Date(new Date().setDate(new Date().getDate() + ((2 + 7 - new Date().getDay()) % 7) - 189));
Expand All @@ -16,7 +17,6 @@ for (let i = 0; i < 26; i++) {
});
}


for (let i = 0; i < 10; i++) {
MOCK_ROSTER_ACTIVITY.push({
profile: {
Expand Down Expand Up @@ -45,3 +45,33 @@ for (let i = 0; i < 10; i++) {
activities: stats
});
}

for (let i = 0; i < 10; i++) {
MOCK_ROSTER_ACTIVITIES_COMBINE.push({
memberProfile: {
profile: {
data: {
userInfo: {
membershipType: 1,
membershipId: i,
displayName: 'User ' + i
},
dateLastPlayed: '2020-07-31T22:00:00Z',
characterIds: ['2305843009478934569']
}
},
id: '1-' + i
// isLoading: false,
// lastNinteyDays: Math.floor(Math.random() * (SECONDS_IN_WEEK * 12) + 1),
// lastMonth: Math.floor(Math.random() * (SECONDS_IN_WEEK * 4) + 1),
// lastWeek: Math.floor(Math.random() * SECONDS_IN_WEEK + 1),
//stats: stats
},
stats: {
lastNinetyDays: Math.floor(Math.random() * (SECONDS_IN_WEEK * 12) + 1),
lastMonth: Math.floor(Math.random() * (SECONDS_IN_WEEK * 4) + 1),
lastWeek: Math.floor(Math.random() * SECONDS_IN_WEEK + 1),
activities: stats
}
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { ActivityBarChartComponent } from './activity-bar-chart.component';

import { withKnobs, select, object, boolean } from '@storybook/addon-knobs';
import { MOCK_GRID_ITEMS, REAL_DATA } from './_MOCK_GRID_ITEMS';
import { LoadingActivityComponent } from './activity-bar-chart.component-story.stories';
import { MaterialModule } from '../../modules/material.module';
import { LoadingModule } from '../../loading/loading.module';
const events = [MOCK_GRID_ITEMS];
Expand All @@ -17,7 +16,6 @@ export default {
withKnobs,
moduleMetadata({
imports: [ActivityBarChartModule, MaterialModule, LoadingModule],
declarations: [LoadingActivityComponent]
})
]
};
Expand Down
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 projects/data/src/lib/stat-aggregators/clan-activity.service.ts
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
};
})
);
}
}
1 change: 1 addition & 0 deletions projects/data/src/lib/stat-aggregators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './clan-dungeon.service';
export * from './clan-crucible.service';
export * from './clan-gambit.service';
export * from './clan-roster.service';
export * from './clan-activity.service';
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,16 @@

<!-- <lib-clan-roster-activity-table [memberActivityStats]="clanMemberActivityService.memberProfileActivities$ | async"
[isLoading]="clanMemberActivityService.areMembersLoading$ | async"></lib-clan-roster-activity-table> -->
<lib-clan-roster-activity-table





<!-- <lib-clan-roster-activity-table
[memberProfiles]="clanMemberActivityService.clanMemberProfiles$ | async"
[memberActivities]="clanMemberActivityService.memberActivities$ | async"
[isLoading]="clanMemberActivityService.areMembersLoading$ | async" [memberProfilesLoading]="clanMemberActivityService.areMemberProfilesLoading$ | async" (viewMember)="viewMember($event)"></lib-clan-roster-activity-table>
[isLoading]="clanMemberActivityService.areMembersLoading$ | async" [memberProfilesLoading]="clanMemberActivityService.areMemberProfilesLoading$ | async" (viewMember)="viewMember($event)"></lib-clan-roster-activity-table> -->

<pre><code>
{{clanMemberActivityService.activityStats | json }}
</code></pre>
34 changes: 20 additions & 14 deletions src/app/clan/clan-member-activity/clan-member-activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,16 @@ import {
getIsMembersProfilesLoaded,
getIsMembersProfilesLoading
} from '../store/member-profiles/member-profiles.selectors';
import { ClanMemberRecentActivityService, getMemberProfileId } from '@destiny/data';
import { ClanActivityService, getMemberProfileId } from '@destiny/data';

import * as clanMemberSelectors from '../store/clan-members/clan-members.selectors';

@Injectable()
export class ClanMemberActivityService {
constructor(private store: Store<ClanState>, private memberActivityService: ClanMemberRecentActivityService) {}
constructor(private store: Store<ClanState>, private clanActivityService: ClanActivityService) {}
isMembersLoaded$ = this.store.pipe(select(getIsMembersProfilesLoaded));
clanId$ = this.store.select(clanIdSelectors.getClanIdState);
clanMembers$ = this.store.select(clanMemberSelectors.getAllMembers);

clanMemberProfiles$ = this.store.pipe(select(getAllMembers));
areMembersLoading$ = this.store.pipe(select(getClanMemberActivitiesLoading));
Expand All @@ -42,27 +45,30 @@ export class ClanMemberActivityService {
activityStats$ = this.preloadedInfo$.pipe(
switchMap(([isMemberLoaded, id, clanMembers]) => {
this.isLoading = true;
this.memberActivityService.getSerializedProfilesActivity(id, clanMembers).pipe(
return this.clanActivityService.getClanActivityStats(id, clanMembers).pipe(
bufferTime(500, undefined, 20),
mergeMap((members) => {
this.activityStats = this.activityStats.concat({
});
this.activityStats = this.activityStats.concat(members);
return members;
}),
toArray(),
map((stats) => {})
map((stats) => {
this.isLoading = false;
})
);
})
);

loadMemberActivity() {
this.isMembersLoaded$
.pipe(
filter((f) => f === true),
take(1)
)
.subscribe((x) => {
this.store.dispatch(loadClanMembersActivities());
});
// this.isMembersLoaded$
// .pipe(
// filter((f) => f === true),
// take(1)
// )
// .subscribe((x) => {
// this.store.dispatch(loadClanMembersActivities());
// });
this.activityStats$.pipe(take(1)).subscribe();
}

// activityStats$ = this.
Expand Down

0 comments on commit 50128c8

Please sign in to comment.