Tournament: log about score undo + match reopen

This commit is contained in:
Kalle 2023-12-05 20:53:08 +02:00
parent be3afcc710
commit dac0c79129
2 changed files with 17 additions and 0 deletions

View File

@ -53,6 +53,7 @@ import {
} from "../tournament-bracket-utils";
import bracketStyles from "../tournament-bracket.css";
import * as TournamentRepository from "~/features/tournament/TournamentRepository.server";
import { logger } from "~/utils/logger";
export const links: LinksFunction = () => [
{
@ -193,6 +194,10 @@ export const action: ActionFunction = async ({ params, request }) => {
scores[1]--;
}
logger.info(
`Undoing score: Position: ${data.position}; User ID: ${user.id}; Match ID: ${match.id}`,
);
sql.transaction(() => {
deleteTournamentMatchGameResultById(lastResult.id);
@ -233,6 +238,10 @@ export const action: ActionFunction = async ({ params, request }) => {
scores[1]--;
}
logger.info(
`Reopening match: User ID: ${user.id}; Match ID: ${match.id}`,
);
try {
sql.transaction(() => {
deleteTournamentMatchGameResultById(lastResult.id);

8
app/utils/logger.ts Normal file
View File

@ -0,0 +1,8 @@
/* eslint-disable no-console */
// stub file to enable different solution later
export const logger = {
info: console.log,
error: console.error,
warn: console.warn,
};