Skip to content

Commit

Permalink
Merge pull request #17 from oleg-balunenko/fix-bar
Browse files Browse the repository at this point in the history
fix(service): Fix bar counter
  • Loading branch information
obalunenko authored Jul 17, 2020
2 parents c1fc255 + 89a83a0 commit 68b7a1e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,28 +360,29 @@ func (svc *Service) processNotMutual(pBar bar.Bar, notMutual []models.User) (int
whitelist := svc.instagram.Whitelist()

LOOP:
for i, nu := range notMutual {
for _, nu := range notMutual {
if errsNum >= errsLimit {
return count, ErrCorrupted
}

if i != 0 {
pBar.Progress() <- struct{}{}
}

select {
case <-svc.ctx.Done():
break LOOP
case <-ticker.C:
if _, ok := whitelist[nu.UserName]; !ok {
if err := svc.UnFollow(nu); err != nil {
log.Errorf("failed to unfollow [%s]: %v", nu.UserName, err)
errsNum++
continue
}
count++
if _, exist := whitelist[nu.UserName]; exist {
continue
}

pBar.Progress() <- struct{}{}

if err := svc.UnFollow(nu); err != nil {
log.Errorf("failed to unfollow [%s]: %v", nu.UserName, err)
errsNum++
continue
}

count++

if count >= svc.instagram.limits.unFollow {
return count, ErrLimitExceed
}
Expand Down

0 comments on commit 68b7a1e

Please sign in to comment.