Last active
October 25, 2021 17:43
-
-
Save jayhuang75/6ece0364def0113dd547289aec008a9e to your computer and use it in GitHub Desktop.
go-train-delay-inline-processor.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| func (a *App) processEmail(email_list *gmail.ListMessagesResponse, total int64) ([]DelayDataSet, error) { | |
| delayDataSet := []DelayDataSet{} | |
| bar := processBar(total, "[email] processing...") | |
| for _, l := range email_list.Messages { | |
| log.Debugf("[processEmail] processing email id: %s\n", l.Id) | |
| msg, err := a.getEmail(l.Id) | |
| if err != nil { | |
| log.Fatalf("[processEmail] Unable to retrieve msg: %v", err) | |
| } | |
| // reduce part | |
| delay_email, mins := getDelayDetails(msg) | |
| if delay_email != "" { | |
| delayData := DelayDataSet{} | |
| // process to get | |
| // departure station | |
| departure, destination := inlineProcessor(delay_email) | |
| delayData.Departure = departure | |
| delayData.Destination = destination | |
| delayData.Mins = mins | |
| // process to get timestamp | |
| delayData.Date = getDateFromHeader(msg) | |
| delayDataSet = append(delayDataSet, delayData) | |
| } | |
| bar.Add(1) | |
| time.Sleep(10 * time.Millisecond) | |
| } | |
| return delayDataSet, nil | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment