Skip to content

Commit

Permalink
Fix performance issues caused by cartesian explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliveriver committed Aug 20, 2024
1 parent 87db1b2 commit 201431f
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion client/src/components/context/WorldContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const WorldContextProvider = ({ children }: PropsWithChildren) => {
submitOrders: async (orders: Order[]) => {
if (!game || !world) return;
const players = game.player ? [game.player] : Object.values(Nation);
submitOrders({ gameId: game.id, players, orders });
await submitOrders({ gameId: game.id, players, orders });
await refetchUntilUpdate();
},
isLoading: isLoading || isSubmitting || isRefetching || isWaitingForAdjudication,
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/api/useSubmitOrders.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ const submitOrders = async ({ gameId, players, orders }: SubmissionRequest) => {
};

const useSubmitOrders = () => {
const { mutate, ...rest } = useMutation({
const { mutateAsync, ...rest } = useMutation({
mutationKey: ['submitOrders'],
mutationFn: submitOrders,
});
return { submitOrders: mutate, ...rest };
return { submitOrders: mutateAsync, ...rest };
};

export default useSubmitOrders;
1 change: 1 addition & 0 deletions server/Repositories/WorldRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public async Task<World> GetWorld(int gameId)
.Include(w => w.Boards).ThenInclude(b => b.Centres)
.Include(w => w.Boards).ThenInclude(b => b.Units)
.Include(w => w.Orders).ThenInclude(o => o.Unit)
.AsSplitQuery() // TODO wrap database operations in shared lock to prevent concurrency issues
.FirstOrDefaultAsync(w => w.GameId == gameId)
?? throw new KeyNotFoundException("World not found");

Expand Down

0 comments on commit 201431f

Please sign in to comment.