Fix bug in updateUsageData that caused it to not record usage data for newly created users

This commit is contained in:
David Dworken 2023-09-24 16:14:05 -07:00
parent 9fda54d4c2
commit 59119823f5
No known key found for this signature in database

View File

@ -5,6 +5,7 @@ import (
"errors" "errors"
"fmt" "fmt"
"net/http" "net/http"
"strings"
"time" "time"
"github.com/DataDog/datadog-go/statsd" "github.com/DataDog/datadog-go/statsd"
@ -152,7 +153,7 @@ func (s *Server) updateUsageData(ctx context.Context, version string, remoteAddr
} }
var usageData []shared.UsageData var usageData []shared.UsageData
usageData, err := s.db.UsageDataFindByUserAndDevice(ctx, userId, deviceId) usageData, err := s.db.UsageDataFindByUserAndDevice(ctx, userId, deviceId)
if err != nil { if err != nil && !strings.Contains(err.Error(), "record not found") {
return fmt.Errorf("db.UsageDataFindByUserAndDevice: %w", err) return fmt.Errorf("db.UsageDataFindByUserAndDevice: %w", err)
} }
if len(usageData) == 0 { if len(usageData) == 0 {