Skip to content
This repository has been archived by the owner on Oct 31, 2021. It is now read-only.

Commit

Permalink
Fixing nil pointer reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotcourant committed Sep 20, 2021
1 parent 3927063 commit d5113cc
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ func (c *Controller) RegisterRoutes(app *iris.Application) {
})
}

app.Get("/health", c.getHealth)

app.Use(func(ctx iris.Context) {
log := c.log.WithFields(logrus.Fields{
"requestId": ctx.GetHeader("X-Request-Id"),
Expand All @@ -148,8 +150,6 @@ func (c *Controller) RegisterRoutes(app *iris.Application) {
})

app.PartyFunc(APIPath, func(p router.Party) {
p.Get("/health", c.getHealth)

p.Use(c.loggingMiddleware)
p.OnAnyErrorCode(func(ctx iris.Context) {
if err := ctx.GetErr(); err != nil {
Expand Down
3 changes: 3 additions & 0 deletions pkg/internal/myownsanity/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ func StringPEqual(a, b *string) bool {
if a != nil && b == nil {
return false
}
if a == nil && b == nil {
return true
}

return *a == *b
}
2 changes: 2 additions & 0 deletions pkg/internal/myownsanity/strings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@ func TestStringPEqual(t *testing.T) {
b := "b"
assert.False(t, StringPEqual(nil, &b), "should not be equal")
}

assert.True(t, StringPEqual(nil, nil), "should be equal")
}
5 changes: 3 additions & 2 deletions pkg/jobs/pull_latest_transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,6 @@ func (j *jobManagerBase) pullLatestTransactions(job *work.Job) (err error) {
plaidIdsToBankIds[bankAccount.PlaidAccountId] = bankAccount.BankAccountId
}

log.Debugf("retrieving transactions for %d bank account(s)", len(itemBankAccountIds))

// Request the last 7 days worth of transactions for update.
start := time.Now().Add(-7 * 24 * time.Hour)
if link.LastSuccessfulUpdate == nil {
Expand All @@ -188,12 +186,15 @@ func (j *jobManagerBase) pullLatestTransactions(job *work.Job) (err error) {
return err
}

log.Debugf("retrieving transactions for %d bank account(s)", len(itemBankAccountIds))
transactions, err := platypus.GetAllTransactions(span.Context(), start, end, itemBankAccountIds)
if err != nil {
log.WithError(err).Error("failed to retrieve transactions from plaid")
return errors.Wrap(err, "failed to retrieve transactions from plaid")
}

log.Debugf("retrieved %d transactions", len(transactions))

if err = j.upsertTransactions(
span.Context(),
log,
Expand Down
2 changes: 2 additions & 0 deletions pkg/jobs/transactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func (j *jobManagerBase) upsertTransactions(
return err
}

log.Debugf("found %d existing transactions", len(transactionsByPlaidId))

transactionsToUpdate := make([]*models.Transaction, 0)
transactionsToInsert := make([]models.Transaction, 0)
now := time.Now().UTC()
Expand Down

0 comments on commit d5113cc

Please sign in to comment.