Skip to content

Commit

Permalink
fix(getAvailableModules): parse ids like 35-232a correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
martenmatrix committed Apr 1, 2024
1 parent 8a3fb69 commit 1bfe455
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/getAvailableModules.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ func isEvent(eventSelection *goquery.Selection) bool {
func extractEvent(eventSelection *goquery.Selection) (Event, error) {
paragraphs := eventSelection.Find("p")

id := paragraphs.Find("a[name='eventLink']").Text()[0:6]
regexForId := regexp.MustCompile("\\d{2}-\\d{3}\\w?")
idText := paragraphs.Find("a[name='eventLink']").Text()
id := regexForId.FindStringSubmatch(idText)[0]

title := paragraphs.Find(".eventTitle").Text()
// something unnecessary whitespace is added in the title at the start or end, remove
Expand Down
4 changes: 2 additions & 2 deletions cmd/getAvailableModules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ func TestGetAvailableModules(t *testing.T) {
<td class="tbdata dl-inner">
<p><strong><a href="/scripts/cfefef3" name="eventLink">64-091 <span class="eventTitle">Exercises Distributed Systems and Systems Security </span></a></strong></p>
<p><strong><a href="/scripts/cfefef3" name="eventLink">64-091a <span class="eventTitle">Exercises Distributed Systems and Systems Security </span></a></strong></p>
<p>Markus Ruehl</p>
<p></p>
</td>
Expand Down Expand Up @@ -344,7 +344,7 @@ func TestGetAvailableModules(t *testing.T) {
RegistrationLink: "", // should be empty, as simulated user is already registered
Events: []Event{
{
Id: "64-091",
Id: "64-091a",
Title: "Exercises Distributed Systems and Systems Security",
Link: stineURL.Url + "/scripts/cfefef3",
MaxCapacity: math.Inf(1),
Expand Down

0 comments on commit 1bfe455

Please sign in to comment.