Both sites/powerball/powerball.go:149-168 and sites/megamillions/megamillions.go:171-190 define identical numericOnly inline functions for parsing jackpot amounts:
Both also have identical jackpot multiplier logic for "Billion" and "Million" suffixes.
Fix
Extract a shared utility function, either in a sites/lottery package or as an exported function in the extractor package.
**Parent:** #3
## Description
Both `sites/powerball/powerball.go:149-168` and `sites/megamillions/megamillions.go:171-190` define identical `numericOnly` inline functions for parsing jackpot amounts:
```go
numericOnly := func(in string) float64 {
var out string
for _, r := range in {
if r >= '0' && r <= '9' {
out += string(r)
}
if r == '.' {
out += string(r)
}
}
val, err := strconv.ParseFloat(out, 64)
if err != nil {
return 0
}
return val
}
```
Both also have identical jackpot multiplier logic for "Billion" and "Million" suffixes.
## Fix
Extract a shared utility function, either in a `sites/lottery` package or as an exported function in the extractor package.
Work finished — extracted identical numericOnly functions from powerball and megamillions into shared sites/internal/parse.NumericOnly with unit tests. Merged in PR #40.
Work finished — extracted identical `numericOnly` functions from powerball and megamillions into shared `sites/internal/parse.NumericOnly` with unit tests. Merged in PR #40.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent: #3
Description
Both
sites/powerball/powerball.go:149-168andsites/megamillions/megamillions.go:171-190define identicalnumericOnlyinline functions for parsing jackpot amounts:Both also have identical jackpot multiplier logic for "Billion" and "Million" suffixes.
Fix
Extract a shared utility function, either in a
sites/lotterypackage or as an exported function in the extractor package.Starting work on this as part of PR 9 (also includes #14). Will extract
numericOnlytosites/internal/parse/parse.go.Work finished — extracted identical
numericOnlyfunctions from powerball and megamillions into sharedsites/internal/parse.NumericOnlywith unit tests. Merged in PR #40.