Skip to content

Commit

Permalink
Fix subscription create query
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenWeathers committed Mar 31, 2024
1 parent f75a17d commit 772f42c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion internal/db/subscription/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (s *Service) CreateSubscription(ctx context.Context, subscription thunderdo
err := s.DB.QueryRowContext(ctx,
`INSERT INTO thunderdome.subscription
(user_id, team_id, organization_id, customer_id, subscription_id, type, expires)
VALUES ($1, NULLIF($2::text,''), NULLIF($3::text,''), $4, $5, $6, $7)
VALUES ($1, NULLIF($2::text,'')::uuid, NULLIF($3::text,'')::uuid, $4, $5, $6, $7)
RETURNING id, user_id, COALESCE(team_id::text, ''), COALESCE(organization_id::text, ''), customer_id, subscription_id, active, type, expires, created_date, updated_date;`,
subscription.UserID, subscription.TeamID, subscription.OrganizationID,
subscription.CustomerID, subscription.SubscriptionID, subscription.Type, subscription.Expires,
Expand Down
8 changes: 7 additions & 1 deletion internal/webhook/subscription/subscription.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,13 @@ func (s *Service) HandleWebhook() http.HandlerFunc {

_, err = s.dataSvc.CreateSubscription(ctx, sub)
if err != nil {
logger.Error(fmt.Sprintf("Error creating subscription: %v", err), zap.String("eventId", event.ID))
logger.Error(fmt.Sprintf("Error creating subscription: %v", err),
zap.String("eventId", event.ID),
zap.String("subUserId", sub.UserID),
zap.String("subId", sub.SubscriptionID),
zap.String("subType", sub.Type),
zap.Time("subExpires", sub.Expires),
)
w.WriteHeader(http.StatusInternalServerError)
return
}
Expand Down

0 comments on commit 772f42c

Please sign in to comment.