commit score on end of play
This commit is contained in:
@@ -299,7 +299,7 @@ export class AuthController {
|
||||
@ApiBearerAuth()
|
||||
@ApiOkResponse({ description: 'Successfully added score'})
|
||||
@ApiUnauthorizedResponse({ description: 'Invalid token' })
|
||||
@Get('me/score/:score')
|
||||
@Patch('me/score/:score')
|
||||
addScore(
|
||||
@Request() req: any,
|
||||
@Param('id') score: number,
|
||||
|
||||
@@ -130,4 +130,18 @@ export class UsersService {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async addScore(
|
||||
where: Prisma.UserWhereUniqueInput,
|
||||
score: number,
|
||||
) {
|
||||
return this.prisma.user.update({
|
||||
where,
|
||||
data: {
|
||||
score: {
|
||||
increment: score,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -697,4 +697,11 @@ export default class API {
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
public static async updateUserTotalScore(score: number): Promise<void> {
|
||||
await API.fetch({
|
||||
route: `/auth/me/score/${score}`,
|
||||
method: 'PATCH',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,6 +145,7 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
|
||||
type: 'end',
|
||||
})
|
||||
);
|
||||
API.updateUserTotalScore(score);
|
||||
};
|
||||
|
||||
const onMIDISuccess = (access: MIDIAccess) => {
|
||||
|
||||
Reference in New Issue
Block a user