Skip to content

Commit

Permalink
refactor(email_processor): simplify UpdateLastProcessed method
Browse files Browse the repository at this point in the history
  • Loading branch information
janyksteenbeek committed Nov 16, 2024
1 parent ef3f6ba commit 3d0d644
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions internal/processor/email_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ func (p *EmailProcessor) ProcessEmails(ctx context.Context) ([]gmail.Email, erro
return emails, nil
}

func (p *EmailProcessor) UpdateLastProcessed(email gmail.Email) error {
p.lastUpdate = email.Date.Add(time.Second)
func (p *EmailProcessor) UpdateLastProcessed() error {
p.lastUpdate = time.Now()
p.cfg.App.LastUpdate = p.lastUpdate.Format(time.RFC3339)

if err := config.SaveConfig(p.cfg); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions internal/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ func (p *Processor) processNewEmails(ctx context.Context) error {
continue
}
}
}

if err := p.emailProcessor.UpdateLastProcessed(email); err != nil {
log.Printf("Failed to update last processed time: %v", err)
}
if err := p.emailProcessor.UpdateLastProcessed(); err != nil {
log.Printf("Failed to update last processed time: %v", err)
}

return nil
Expand Down

0 comments on commit 3d0d644

Please sign in to comment.