test removed
This commit is contained in:
@@ -1,66 +0,0 @@
|
||||
import e, { Router } from 'express';
|
||||
import { container, DIContainer } from '../../Application/Services/DIContainer';
|
||||
import { ErrorResponseService } from '../../Application/Services/ErrorResponseService';
|
||||
import { logRequest, logError, logAuth, logWarning, logOther } from '../../Application/Services/Logger';
|
||||
import { GenerateBoardCommand } from '../../Application/Game/commands/GenerateBoardCommand';
|
||||
|
||||
const router = Router();
|
||||
|
||||
//function to test the search service
|
||||
async function triggerAsyncBoardGeneration(gameId: string): Promise<boolean> {
|
||||
try {
|
||||
// Calculate default field counts based on game configuration
|
||||
// For now, use reasonable defaults - this should be configurable by host in the future
|
||||
const maxSpecialFieldsPercentage = parseInt(process.env.MAX_SPECIAL_FIELDS_PERCENTAGE || '67');
|
||||
const maxSpecialFields = Math.floor((100 * maxSpecialFieldsPercentage) / 100);
|
||||
|
||||
// Default distribution: 60% positive, 25% negative, 15% luck
|
||||
const positiveFieldCount = Math.floor(maxSpecialFields * 0.6);
|
||||
const negativeFieldCount = Math.floor(maxSpecialFields * 0.25);
|
||||
const luckFieldCount = Math.floor(maxSpecialFields * 0.15);
|
||||
|
||||
const command: GenerateBoardCommand = {
|
||||
gameId,
|
||||
positiveFieldCount,
|
||||
negativeFieldCount,
|
||||
luckFieldCount
|
||||
};
|
||||
|
||||
logOther(`Triggering async board generation for game ${gameId}`, {
|
||||
positiveFieldCount,
|
||||
negativeFieldCount,
|
||||
luckFieldCount,
|
||||
totalSpecialFields: positiveFieldCount + negativeFieldCount + luckFieldCount
|
||||
});
|
||||
|
||||
// Execute board generation in background
|
||||
await DIContainer.getInstance().generateBoardCommandHandler.execute(command);
|
||||
return true;
|
||||
|
||||
} catch (error) {
|
||||
logError(`Async board generation failed for game ${gameId}`, error as Error);
|
||||
// Don't propagate error - board generation failure shouldn't affect game creation
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Game board generation endpoint
|
||||
router.post('/gameBoardGeneration', async (req, res) => {
|
||||
try {
|
||||
logRequest('Game board generation endpoint accessed', req, res);
|
||||
|
||||
const result = await triggerAsyncBoardGeneration("######-#####-#####-######");
|
||||
|
||||
if (result) {
|
||||
logOther('Game board generation triggered successfully', result);
|
||||
return res.json({ message: 'Game board generation triggered successfully' });
|
||||
} else {
|
||||
throw new Error('Game board generation failed to trigger');
|
||||
}
|
||||
} catch (error : any) {
|
||||
logError('Error in game board generation endpoint', error);
|
||||
return ErrorResponseService.sendInternalServerError(res);
|
||||
}
|
||||
});
|
||||
export default router;
|
||||
Reference in New Issue
Block a user