Skip to content

Commit

Permalink
Merge pull request #496 from SprocketBot/personal/gankoji/MakeEloRedi…
Browse files Browse the repository at this point in the history
…stroWork

fix: bugs in elo redistro mutations
  • Loading branch information
gankoji committed Aug 12, 2023
2 parents 62e2de7 + ec65ad6 commit 4f59dc3
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions core/src/franchise/player/player.resolver.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
forwardRef, Inject, UseGuards,
forwardRef, Inject, Logger, UseGuards,
} from "@nestjs/common";
import {
Args,
Expand Down Expand Up @@ -77,6 +77,8 @@ export class PlayerResolver {
@Inject(forwardRef(() => OrganizationService)) private readonly organizationService: OrganizationService,
) {}

private readonly logger = new Logger(PlayerResolver.name);

@ResolveField()
async skillGroup(@Root() player: Player): Promise<GameSkillGroup> {
return this.popService.populateOneOrFail(Player, player, "skillGroup");
Expand Down Expand Up @@ -247,21 +249,6 @@ export class PlayerResolver {
): Promise<string> {
const player = await this.playerService.getPlayer({
where: {id: playerId},
relations: {
member: {
user: {
authenticationAccounts: true,
},
organization: true,
profile: true,
},
skillGroup: {
id: true,
organization: true,
game: true,
profile: true,
},
},
});

const inputData: ManualEloChange = {
Expand All @@ -274,10 +261,11 @@ export class PlayerResolver {
await this.playerService.updatePlayerStanding(playerId, salary, player.skillGroupId);
await this.eloConnectorService.createJob(EloEndpoint.EloChange, inputData);

this.logger.verbose(`Successfully changed ${playerId}'s salary to ${salary} and elo to ${elo}.`);
return "SUCCESS";
}

@Mutation(() => [Player])
@Mutation(() => String)
@UseGuards(GqlJwtGuard, MLEOrganizationTeamGuard([MLE_OrganizationTeam.MLEDB_ADMIN, MLE_OrganizationTeam.LEAGUE_OPERATIONS]))
async changePlayerEloBulk(@Args("files", {type: () => [GraphQLUpload]}) files: Array<Promise<FileUpload>>): Promise<string> {
const csvs = await Promise.all(files.map(async f => f.then(async _f => readToString(_f.createReadStream()))));
Expand Down

0 comments on commit 4f59dc3

Please sign in to comment.