Skip to content

Commit

Permalink
Update oracle.go
Browse files Browse the repository at this point in the history
  • Loading branch information
nnn-gif committed Aug 22, 2024
1 parent 4f3b793 commit f4cc2f8
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions pkg/model/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1207,16 +1207,21 @@ func (reldb *RelDB) GetCustomerByPublicKey(publicKey string) (*Customer, error)
INNER JOIN wallet_public_keys wpk ON c.customer_id = wpk.customer_id
WHERE wpk.public_key = $1
`
var emailsql sql.NullString
var (
emailSql sql.NullString
customerPlanSql sql.NullInt16
paymentStatusSql sql.NullString
paymentSourceSql sql.NullString
)
err := reldb.postgresClient.QueryRow(context.Background(), query, publicKey).Scan(
&customer.CustomerID,
&emailsql,
&emailSql,
&customer.AccountCreationDate,
&customer.CustomerPlan,
&customerPlanSql,
&customer.DeployedOracles,
&customer.PaymentStatus,
&paymentStatusSql,
// &customer.LastPayment,
&customer.PaymentSource,
&paymentSourceSql,
&customer.NumberOfDataFeeds,
&customer.Active,
)
Expand All @@ -1242,8 +1247,17 @@ func (reldb *RelDB) GetCustomerByPublicKey(publicKey string) (*Customer, error)
customer.PublicKeys = append(customer.PublicKeys, publicKey)
}

if emailsql.Valid {
customer.Email = emailsql.String
if emailSql.Valid {
customer.Email = emailSql.String
}
if paymentStatusSql.Valid {
customer.PaymentStatus = paymentStatusSql.String
}
if customerPlanSql.Valid {
customer.CustomerPlan = int(customerPlanSql.Int16)
}
if paymentSourceSql.Valid {
customer.PaymentSource = paymentSourceSql.String
}

if rows.Err() != nil {
Expand Down

0 comments on commit f4cc2f8

Please sign in to comment.