Skip to content

Commit

Permalink
v2024.06.01
Browse files Browse the repository at this point in the history
  • Loading branch information
jonassimoen committed Jun 2, 2024
1 parent c6bdf41 commit b7585b4
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 14 deletions.
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ enum PlayerBoosterType {
HiddenGem
GoalRush
TripleCaptain
FanFavourit
FanFavourite
}

model User {
Expand Down
6 changes: 2 additions & 4 deletions src/controllers/Team.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SavePlayersToJson, finalWeekId, upcomingWeekId, validateStartingLineup } from '../utils/Common';
import { finalWeekId, upcomingWeekId, validateStartingLineup } from '../utils/Common';
import { prisma } from "../db/client"
import HttpError from "../utils/HttpError";
import { max } from "lodash";
Expand Down Expand Up @@ -50,6 +50,7 @@ const CheckValidTeam = async (allPlayerIds: number[], reqBody: any, weekId: numb
throw new HttpError("Too much players of the same club", 403);
}
// 3. Within budget
console.log(allPlayers);
const totalValue = allPlayers.reduce((prev, curr) => ({ id: 0, value: (prev.value || 0) + (curr.value || 0) }), { id: 0, value: 0 }).value || 0;
const budget = 100 - totalValue;
if (budget <= 0) {
Expand Down Expand Up @@ -133,7 +134,6 @@ export const PostAddTeamHandler = async (req: any, rep: any) => {
}
}),
])
SavePlayersToJson();
rep.send({
user: team.user,
team: {
Expand Down Expand Up @@ -503,7 +503,6 @@ export const PostEditTeamHandler = async (req: any, rep: any) => {
}
})
]);
SavePlayersToJson();
rep.send({
message: "Team successfully updated."
});
Expand Down Expand Up @@ -647,7 +646,6 @@ export const PostTransfersTeamHandler = async (req: any, rep: any) => {
}
});
});
SavePlayersToJson();
rep.send({ msg: "Transfers toegekend" });
} else {
rep.status(406).send({ msg: "No transfers included." });
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const PaymentIntentHandler = async (req: any, rep: any) => {
});

await stripe.paymentIntents.create({
amount: 500,
amount: 1040,
currency: "eur",
automatic_payment_methods: {
enabled: true,
Expand Down
8 changes: 0 additions & 8 deletions src/utils/Common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,4 @@ export const validateStartingLineup = (starting: number[]) => {
((starting[2] >= 3) && (starting[2] <= 5)) && // 3-5 DEF
((starting[3] >= 3) && (starting[3] <= 5)) && // 3-5 MID
((starting[4] >= 1) && (starting[4] <= 3)) // 1-3 FOR
}

export const SavePlayersToJson = async () => {
const players = await prisma.player.findMany({});

await fs.writeFile('static/players.json', JSON.stringify(players), (err) => {
if (err) throw err;
});
}

0 comments on commit b7585b4

Please sign in to comment.