Skip to content

Commit 23d5968

Browse files
committed
Small fixes to latest commit
1 parent d1d39b9 commit 23d5968

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

scrapers/coursebook.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func ScrapeCoursebook(term string, startPrefix string, outDir string) {
7070
// String builder to store accumulated course HTML data for both class levels
7171
courseBuilder := strings.Builder{}
7272

73-
log.Printf("Finding sections for course prefix %s...", coursePrefix)
73+
log.Printf("Finding sections for %s...", coursePrefix)
7474

7575
// Get courses for term and prefix, split by grad and undergrad to avoid 300 section cap
7676
for _, clevel := range []string{"clevel_u", "clevel_g"} {
@@ -90,7 +90,7 @@ func ScrapeCoursebook(term string, startPrefix string, outDir string) {
9090
}
9191
return err
9292
}, 10, func(numRetries int) {
93-
log.Printf("WARN: Section find for course prefix %s failed! Performing retry #%d...", coursePrefix, numRetries)
93+
log.Printf("WARN: Section find for %s failed! Performing retry #%d...", coursePrefix, numRetries)
9494
coursebookHeaders = utils.RefreshToken(chromedpCtx)
9595
// Wait proportionally long to how many times we've retried; generally works pretty well
9696
time.Sleep(500 * time.Millisecond * time.Duration(numRetries))
@@ -111,7 +111,7 @@ func ScrapeCoursebook(term string, startPrefix string, outDir string) {
111111
for _, matchSet := range smatches {
112112
sectionIDs = append(sectionIDs, matchSet[1])
113113
}
114-
log.Printf("Found %d sections for course prefix %s", len(sectionIDs), coursePrefix)
114+
log.Printf("Found %d sections for %s", len(sectionIDs), coursePrefix)
115115

116116
// Get a new token before starting the section lookup
117117
coursebookHeaders = utils.RefreshToken(chromedpCtx)
@@ -140,7 +140,7 @@ func ScrapeCoursebook(term string, startPrefix string, outDir string) {
140140
}
141141
return err
142142
}, 10, func(numRetries int) {
143-
log.Printf("WARN: Section id lookup for id %s failed! Performing retry #%d...", id, numRetries)
143+
log.Printf("WARN: Section id lookup for %s failed! Performing retry #%d...", id, numRetries)
144144
coursebookHeaders = utils.RefreshToken(chromedpCtx)
145145
// Wait proportionally long to how many times we've retried; generally works pretty well
146146
time.Sleep(500 * time.Millisecond * time.Duration(numRetries))
@@ -171,10 +171,10 @@ func ScrapeCoursebook(term string, startPrefix string, outDir string) {
171171
}
172172
sectionsInCoursePrefix++
173173
}
174-
log.Printf("Finished scraping course prefix %s. Got %d sections.\n----------------------------------------------------", coursePrefix, sectionsInCoursePrefix)
174+
log.Printf("Finished scraping %s. Got %d sections.\n----------------------------------------------------", coursePrefix, sectionsInCoursePrefix)
175175
// Panic if we got fewer sections than we should've
176176
if sectionsInCoursePrefix != len(sectionIDs) {
177-
log.Panicf("Section count mismatch! Expected sections %d for %s, got %d", sectionsInCoursePrefix, coursePrefix, sectionsInCoursePrefix)
177+
log.Panicf("Section count mismatch! Expected %d sections for %s, got %d", sectionsInCoursePrefix, coursePrefix, sectionsInCoursePrefix)
178178
}
179179
totalSections += sectionsInCoursePrefix
180180
}

uploader/uploader.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ func UploadData[T any](client *mongo.Client, ctx context.Context, fptr *os.File,
133133
if err != nil {
134134
log.Panic(err)
135135
}
136+
log.Println("Done sorting courses!")
136137
}
137138

138139
} else {

0 commit comments

Comments
 (0)