Skip to content

Commit cd8af9a

Browse files
author
Chomp
committed
Lint file
1 parent b053235 commit cd8af9a

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

project/src/controllers/BotController.ts

+7-15
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ export class BotController {
156156
const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
157157

158158
// If we don't have enough bots cached to satisfy this request, populate the cache
159-
if (!this.cacheSatisfiesRequest(info))
160-
{
159+
if (!this.cacheSatisfiesRequest(info)) {
161160
await this.generateAndCacheBots(info, pmcProfile, sessionId);
162161
}
163162

@@ -166,16 +165,13 @@ export class BotController {
166165

167166
/**
168167
* Return true if the current cache satisfies the passed in bot generation request
169-
* @param info
170-
* @returns
168+
* @param info
169+
* @returns
171170
*/
172171
public cacheSatisfiesRequest(info: IGenerateBotsRequestData): boolean {
173172
return info.conditions.every((condition) => {
174173
// Create the key that would be used for caching this bot type, so we can check how many exist
175-
const cacheKey = this.botGenerationCacheService.createCacheKey(
176-
condition.Role,
177-
condition.Difficulty
178-
);
174+
const cacheKey = this.botGenerationCacheService.createCacheKey(condition.Role, condition.Difficulty);
179175

180176
return this.botGenerationCacheService.getCachedBotCount(cacheKey) >= condition.Limit;
181177
});
@@ -202,13 +198,9 @@ export class BotController {
202198
// Map conditions to promises for bot generation
203199
const conditionPromises = request.conditions.map(async (condition) => {
204200
// If we already have enough for this bot type, don't generate more
205-
const cacheKey = this.botGenerationCacheService.createCacheKey(
206-
condition.Role,
207-
condition.Difficulty
208-
);
201+
const cacheKey = this.botGenerationCacheService.createCacheKey(condition.Role, condition.Difficulty);
209202

210-
if (this.botGenerationCacheService.getCachedBotCount(cacheKey) >= condition.Limit)
211-
{
203+
if (this.botGenerationCacheService.getCachedBotCount(cacheKey) >= condition.Limit) {
212204
return;
213205
}
214206

@@ -327,7 +319,7 @@ export class BotController {
327319
// Get number of bots we have in cache
328320
const botCacheCount = this.botGenerationCacheService.getCachedBotCount(cacheKey);
329321

330-
if (botCacheCount >= botGenerationDetails.botCountToGenerate) {
322+
if (botCacheCount > botGenerationDetails.botCountToGenerate) {
331323
this.logger.debug(`Cache already has sufficient ${cacheKey} bots: ${botCacheCount}, skipping generation`);
332324
return;
333325
}

0 commit comments

Comments
 (0)