Skip to content

improved discount parser#147

Merged
mikehquan19 merged 2 commits intoUTDNebula:developfrom
bvaic:develop
Mar 30, 2026
Merged

improved discount parser#147
mikehquan19 merged 2 commits intoUTDNebula:developfrom
bvaic:develop

Conversation

@bvaic
Copy link
Copy Markdown
Contributor

@bvaic bvaic commented Mar 27, 2026

  • addresses are now parsed into a []string of addresses
  • phonenumber package is used to normalize phone numbers to 1XXXXXXXXXX where 1 is country code
  • discount parser test cases updated and passed

Co-authored-by: kimbow231 kimbow685@gmail.com

Fixes: #144

* addresses are now parsed into a []string of addresses
* phonenumber package is used to normalize phone numbers to 1XXXXXXXXXX where 1 is country code
* discount parser test cases updated and passed
Copy link
Copy Markdown
Contributor

@mikehquan19 mikehquan19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bvaic, your code works but i give some extra small sub-issues so can you look into them for me?

Also, can you include the github of your co-author here?

@@ -135,21 +136,24 @@ func parseDiscountItem(s *goquery.Selection, category string) *schema.DiscountPr

// Check if it's a phone number
if containsPhonePattern(line) || isNumericPhone(line) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These may be some extra tasks, but can you dig into these two checking functions and see if there is a way of rewriting it using regex instead of for-loop or string matching?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sure, I think it would be possible to put some regex into the containsPhonePattern() and maybe just leave isNumericPhone() as a fallback in case none of the regex matches

* the phonenumber package now handles checking if a line is a phone number
* removed the containsPhonePattern() and isNumericPhone() functions as they are no longer needed
* the extractEmail() function now uses regex to extract emails instead of for loops
* discountParser_test.go updated to remove tests that are no longer needed
Copy link
Copy Markdown
Contributor

@mikehquan19 mikehquan19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@mikehquan19 mikehquan19 merged commit 767669b into UTDNebula:develop Mar 30, 2026
0 of 2 checks passed
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.

Modify the discounts program parser

2 participants