commit score on end of play

This commit is contained in:
danis
2023-10-08 21:53:58 +02:00
parent 0473665bb4
commit 06bfc181c7
4 changed files with 23 additions and 1 deletions
+1 -1
View File
@@ -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,
+14
View File
@@ -130,4 +130,18 @@ export class UsersService {
}
)
}
async addScore(
where: Prisma.UserWhereUniqueInput,
score: number,
) {
return this.prisma.user.update({
where,
data: {
score: {
increment: score,
},
},
});
}
}
+7
View File
@@ -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',
});
}
}
+1
View File
@@ -145,6 +145,7 @@ const PlayView = ({ songId, type, route }: RouteProps<PlayViewProps>) => {
type: 'end',
})
);
API.updateUserTotalScore(score);
};
const onMIDISuccess = (access: MIDIAccess) => {