Skip to content

Commit

Permalink
Update list date on import before notif and run notif as a goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
knadh committed May 14, 2019
1 parent 8701cb4 commit 3a6f15e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ func main() {

// Initialize the bulk subscriber importer.
importNotifCB := func(subject string, data map[string]interface{}) error {
return sendNotification(notifTplImport, subject, data, app)
go sendNotification(notifTplImport, subject, data, app)
return nil
}
app.Importer = subimporter.New(q.UpsertSubscriber.Stmt,
q.UpsertBlacklistSubscriber.Stmt,
Expand Down
7 changes: 2 additions & 5 deletions subimporter/importer.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,10 @@ func (s *Session) Start() {
if cur == 0 {
s.im.setStatus(StatusFinished)
s.log.Printf("imported finished")
s.im.sendNotif(StatusFinished)

if _, err := s.im.updateListDate.Exec(listIDs); err != nil {
s.log.Printf("error updating lists date: %v", err)
}

s.im.sendNotif(StatusFinished)
return
}

Expand All @@ -298,11 +296,10 @@ func (s *Session) Start() {
s.im.incrementImportCount(cur)
s.im.setStatus(StatusFinished)
s.log.Printf("imported finished")
s.im.sendNotif(StatusFinished)

if _, err := s.im.updateListDate.Exec(listIDs); err != nil {
s.log.Printf("error updating lists date: %v", err)
}
s.im.sendNotif(StatusFinished)
}

// Stop stops an active import session.
Expand Down

0 comments on commit 3a6f15e

Please sign in to comment.