From e0579fbcbd8a9dc783bc14d4e902219b131fc33e Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Thu, 22 Jul 2021 20:22:46 -0400 Subject: [PATCH] fix up for render --- internal/cmd/api.go | 2 +- internal/cmd/scheduler.go | 8 +++++--- internal/cmdutil/cmdutil.go | 4 ++-- internal/data/accounts.go | 6 +----- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/internal/cmd/api.go b/internal/cmd/api.go index d3a5c6e..0e336dc 100644 --- a/internal/cmd/api.go +++ b/internal/cmd/api.go @@ -32,7 +32,7 @@ func APICmd(ctx context.Context) *cobra.Command { } defer statsd.Close() - db, err := cmdutil.NewDatabasePool(ctx, 32) + db, err := cmdutil.NewDatabasePool(ctx, 1) if err != nil { return err } diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index 2b00cc8..2814974 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -141,9 +141,11 @@ func cleanAccounts(ctx context.Context, logger *logrus.Logger, pool *pgxpool.Poo return } - logger.WithFields(logrus.Fields{ - "count": count, - }).Info("cleaned stale accounts") + if count > 0 { + logger.WithFields(logrus.Fields{ + "count": count, + }).Info("cleaned stale accounts") + } } func cleanQueues(ctx context.Context, logger *logrus.Logger, jobsConn rmq.Connection) { diff --git a/internal/cmdutil/cmdutil.go b/internal/cmdutil/cmdutil.go index f8ccd02..7e61ce5 100644 --- a/internal/cmdutil/cmdutil.go +++ b/internal/cmdutil/cmdutil.go @@ -32,11 +32,11 @@ func NewStatsdClient(tags ...string) (*statsd.Client, error) { tags = append(tags, fmt.Sprintf("env:%s", env)) } - return statsd.New("127.0.0.1:8125", statsd.WithTags(tags)) + return statsd.New(os.Getenv("STATSD_URL"), statsd.WithTags(tags)) } func NewRedisClient(ctx context.Context) (*redis.Client, error) { - opt, err := redis.ParseURL(os.Getenv("REDISCLOUD_URL")) + opt, err := redis.ParseURL(os.Getenv("REDIS_URL")) if err != nil { return nil, err } diff --git a/internal/data/accounts.go b/internal/data/accounts.go index 08ba2fb..68bdf00 100644 --- a/internal/data/accounts.go +++ b/internal/data/accounts.go @@ -38,9 +38,7 @@ func (am *AccountModel) Upsert(a *Account) error { UPDATE SET access_token = $3, refresh_token = $4, - expires_at = $5, - last_message_id = $6, - last_checked_at = $7 + expires_at = $5 RETURNING id` return tx.QueryRow( am.ctx, @@ -50,8 +48,6 @@ func (am *AccountModel) Upsert(a *Account) error { a.AccessToken, a.RefreshToken, a.ExpiresAt, - a.LastMessageID, - a.LastCheckedAt, ).Scan(&a.ID) }) }