Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit d57e9be

Browse files
committed
Clarify name of courses map
1 parent 6b56e97 commit d57e9be

3 files changed

Lines changed: 5 additions & 5 deletions

File tree

src/guild-context.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export class GuildContext {
3333
* The list of allowed courses that users can be assigned to.
3434
* May be empty if the list could not be populated automatically.
3535
*/
36-
public courses: { [majorPrefix: string]: Course[] };
36+
public coursesByMajor: { [majorPrefix: string]: Course[] };
3737

3838
public verificationRoleId: string;
3939

@@ -51,7 +51,7 @@ export class GuildContext {
5151

5252
private async init(): Promise<void> {
5353
this.guildLog("Initializing course lists...");
54-
this.courses = await CourseService.fetchCourseList(this, new WebCatalogFactory().getWebCatalog(this.guildConfig.webCatalog))
54+
this.coursesByMajor = await CourseService.fetchCourseList(this, new WebCatalogFactory().getWebCatalog(this.guildConfig.webCatalog))
5555
.catch(err => {
5656
this.guildError("Failed to get course lists from the web catalog:", err);
5757

src/services/course.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class CourseService {
3636
* @returns The course if it could be found in the cache, otherwise null.
3737
*/
3838
public static findCourseByKey(guildContext: GuildContext, key: string): Course | null {
39-
const allCourses = _.flatMap(guildContext.courses);
39+
const allCourses = _.flatMap(guildContext.coursesByMajor);
4040
return allCourses.find(c => c.key == key);
4141
}
4242

@@ -49,7 +49,7 @@ export class CourseService {
4949
* @returns The course if valid, undefined if not.
5050
*/
5151
public static async getCourseFromNumber(guildContext: GuildContext, number: string, major: Major): Promise<Course> {
52-
const majorCourses = guildContext.courses[major.prefix];
52+
const majorCourses = guildContext.coursesByMajor[major.prefix];
5353
if (majorCourses.length === 0) {
5454
return {
5555
key: CourseUtils.getKey(number, major),

src/services/discord/role-assignment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class DiscordRoleAssignmentService {
2525

2626
// Courses
2727
//TODO: Won't work for non-catalog majors
28-
for(let courses of Object.values(guildContext.courses)) {
28+
for(let courses of Object.values(guildContext.coursesByMajor)) {
2929
for(let course of courses) {
3030
const assignment = user.guilds.get(guildContext.guild.id).courses.find(courseAssignment => courseAssignment.courseKey === course.key);
3131
if(assignment) { // User is assigned to course.

0 commit comments

Comments
 (0)