filter accounts by pattern
This commit is contained in:
5
main.go
5
main.go
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"local/sandbox/contact/contact"
|
||||
"log"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -16,12 +17,16 @@ func main() {
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
patterns := regexp.MustCompile(config.AccountsPattern)
|
||||
for email := range emails {
|
||||
transactions, err := Scrape(email, config.Banks)
|
||||
if err != nil {
|
||||
log.Println("failed to scrape email:", err)
|
||||
}
|
||||
for _, transaction := range transactions {
|
||||
if !patterns.MatchString(transaction.Account) {
|
||||
log.Printf("skipping unmatching account pattern %q vs %q", config.AccountsPattern, transaction.Account)
|
||||
}
|
||||
if _, err := config.Storage.Get(transaction.ID); err == nil {
|
||||
log.Println("skipping duplicate transaction:", transaction)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user