@@ -440,10 +440,10 @@ export class AojCoursesApiClient extends AojTasksApiClientBase {
440440export class AojChallengesApiClient extends AojTasksApiClientBase < ChallengeParams > {
441441 async getContests ( params : ChallengeParams ) : Promise < ContestsForImport > {
442442 const { contestType, round } = params ;
443- const cacheKey = `aoj_ ${ contestType . toLowerCase ( ) } _ ${ round . toLowerCase ( ) } ` ;
443+ const cacheKey = this . getCacheKey ( contestType , round ) ;
444444
445445 const contests = await this . cache . getCachedOrFetchContests ( cacheKey , async ( ) => {
446- const contestTypeLabel = contestType . toUpperCase ( ) ;
446+ const contestTypeLabel = this . getContestTypeLabel ( contestType ) ;
447447
448448 const results = await this . httpClient . fetchApiWithConfig < AOJChallengeContestAPI > ( {
449449 endpoint : this . buildEndpoint ( [ 'challenges' , 'cl' , contestType , round ] ) ,
@@ -475,10 +475,10 @@ export class AojChallengesApiClient extends AojTasksApiClientBase<ChallengeParam
475475
476476 async getTasks ( params : ChallengeParams ) : Promise < TasksForImport > {
477477 const { contestType, round } = params ;
478- const cacheKey = `aoj_ ${ contestType . toLowerCase ( ) } _ ${ round . toLowerCase ( ) } ` ;
478+ const cacheKey = this . getCacheKey ( contestType , round ) ;
479479
480480 const tasks = await this . cache . getCachedOrFetchTasks ( cacheKey , async ( ) => {
481- const contestTypeLabel = contestType . toUpperCase ( ) ;
481+ const contestTypeLabel = this . getContestTypeLabel ( contestType ) ;
482482
483483 const allChallengeContests = await this . httpClient . fetchApiWithConfig < AOJChallengeContestAPI > (
484484 {
@@ -510,4 +510,30 @@ export class AojChallengesApiClient extends AojTasksApiClientBase<ChallengeParam
510510
511511 return tasks ;
512512 }
513+
514+ /**
515+ * Generates a unique cache key for Aizu Online Judge contest data.
516+ *
517+ * @param contestType - The type of the contest
518+ * @param round - The round of the contest, specific to the contest type
519+ * @returns A string in the format "aoj_[contestType]_[round]" with lowercase values
520+ * @private
521+ */
522+ private getCacheKey (
523+ contestType : ChallengeContestType ,
524+ round : ChallengeRoundMap [ ChallengeContestType ] ,
525+ ) : string {
526+ return `aoj_${ contestType . toLowerCase ( ) } _${ round . toLowerCase ( ) } ` ;
527+ }
528+
529+ /**
530+ * Converts the contest type to an uppercase string representation.
531+ *
532+ * @param contestType - The type of contest to convert
533+ * @returns The uppercase string representation of the contest type
534+ * @private
535+ */
536+ private getContestTypeLabel ( contestType : ChallengeContestType ) : string {
537+ return contestType . toUpperCase ( ) ;
538+ }
513539}
0 commit comments