Skip to content

Fixed Issue #194 - #209

Open
PaperBagTrick wants to merge 1 commit into
developfrom
issue-194
Open

PaperBagTrick wants to merge 1 commit into
developfrom
issue-194

Conversation

@PaperBagTrick

Copy link
Copy Markdown

Description

Previously, cometCalendarParser and mazevoParser would take data scraped from Comet Calendar and Mazevo respectively, and put it into a triple nested map. Then, this map's data would be sent to an array of MultiBuildingEvents called result.
This caused a sorting issue, since data in a hashmap is not sorted.

This pull request adds code to sort the array of MultiBuildingEvents called result before it's data is written to a json file of parsed data. It does this in both cometCalendarParser and mazevoParser

MultiBuildingEvents, from the nebula-api schema library, is a struct containing an array of SingleBuildingEvents, which contains an array of RoomEvents, which contains an array of any object (in this case, Event). Each also holds a string variable (date -> building -> room -> id).

The code now includes a nested for loop using indexes and the slices.sortFunc(...) method from the go slices library to sort each of these arrays by their string variable (date -> building -> room -> id).
The sorting functions are unique to each array. For date, it's sorted by ascending date. building and room are alphabetical, and id is by the hex encoding (uses the .Hex() method).

Extra comments were also added explaining the purpose of the new nested for loop, the random order of iterating through maps, and the schema of the result variable.

Testing

for cometCalendarParser...

  1. After adding my code, build the project.
  2. In the terminal, do Run ./api-tools -scrape -cometCalendar
  3. In the terminal, do Run ./api-tools -parse -cometCalendar
  4. Open data/cometCalendar.json
  5. Do Ctrl+f and search for "date", "building", "room", or "_id" (include quotations in search)
  6. Click the down or up arrows to the left of the search box to go to next/previous entry
  7. Click this multiple times while looking at the strings to their right. You will see they are all sorted
  8. again, do Run ./api-tools -parse -cometCalendar as many times as you want
  9. cometCalendar.json should stay exactly the same each time. If it doesn't, the test fails.

for mazevoParser...

  1. After adding my code, build the project.
  2. In the terminal, do Run ./api-tools -scrape -mazevo
  3. In the terminal, do Run ./api-tools -parse -mazevo
  4. Open data/mazevo.json
  5. Do Ctrl+f and search for "date", "building", "room", or "eventName" (include quotations in search)
  6. Click the down or up arrows to the left of the search box to go to next/previous entry
  7. Click this multiple times while looking at the strings to their right. You will see they are all sorted
  8. again, do Run ./api-tools -parse -mazevo as many times as you want
  9. cometCalendar.json should stay exactly the same each time. If it doesn't, the test fails.

AI Disclosure

It should be noted that during the preparation of this project, Generative AI tools (including Claude and Gemini) were used to debug parsing issues, help using git commands, structure the PR documentation, and give general examples of sorting Go map keys with slices.SortFunc(...).

I have checked, run, and modified every line of the code generated by AI to achieve a thorough understanding of it, as well as ensure its correctness and compliance with the principles of academic integrity.

I wrote and applied the changes to cometCalendarParser.go and mazevoParser.go myself and tested them locally.

  • Integrity Compliance: No automated code generation, copy-pasted logic, or algorithmic solutions were used to solve the core issue. My code implementation is an original piece of work and should not be considered as academic dishonesty.

Checklist

  • Create this PR
  • Merge code to main

@PaperBagTrick
PaperBagTrick requested review from a team as code owners October 17, 2026 03:40
@PaperBagTrick PaperBagTrick linked an issue Oct 19, 2026 that may be closed by this pull request

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make parser output order stable

1 participant