Skip to content

Commit

Permalink
api: update product-summary: add validators_per_dashboard_limit
Browse files Browse the repository at this point in the history
  • Loading branch information
guybrush committed Jun 11, 2024
1 parent 17e237d commit 4260130
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
15 changes: 10 additions & 5 deletions backend/pkg/api/data_access/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type UserRepository interface {
}

func (d *DataAccessService) GetUserCredentialInfo(email string) (*t.UserCredentialInfo, error) {
// TODO @patrick
// TODO @patrick post-beta improve product-mgmt
result := &t.UserCredentialInfo{}
err := d.userReader.Get(result, `
WITH
Expand Down Expand Up @@ -61,7 +61,7 @@ func (d *DataAccessService) GetUserIdByApiKey(apiKey string) (uint64, error) {
}

func (d *DataAccessService) GetUserInfo(userId uint64) (*t.UserInfo, error) {
// TODO @patrick improve and unmock
// TODO @patrick post-beta improve and unmock
userInfo := &t.UserInfo{
Id: userId,
ApiKeys: []string{},
Expand Down Expand Up @@ -201,14 +201,19 @@ func (d *DataAccessService) GetUserInfo(userId uint64) (*t.UserInfo, error) {
}
}

if productSummary.ValidatorsPerDashboardLimit < userInfo.PremiumPerks.ValidatorsPerDashboard {
userInfo.PremiumPerks.ValidatorsPerDashboard = productSummary.ValidatorsPerDashboardLimit
}

return userInfo, nil
}

func (d *DataAccessService) GetProductSummary() (*t.ProductSummary, error) {
// TODO @patrick put into db instead of hardcoding here and make it configurable
// TODO @patrick post-beta put into db instead of hardcoding here and make it configurable
return &t.ProductSummary{
StripePublicKey: utils.Config.Frontend.Stripe.PublicKey,
ApiProducts: []t.ApiProduct{ // TODO @patrick this data is not final yet
ValidatorsPerDashboardLimit: 1_001_000,
StripePublicKey: utils.Config.Frontend.Stripe.PublicKey,
ApiProducts: []t.ApiProduct{ // TODO @patrick post-beta this data is not final yet
{
ProductId: "api_free",
ProductName: "Free",
Expand Down
3 changes: 2 additions & 1 deletion backend/pkg/api/types/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const ProductStoreEthpool ProductStore = "ethpool"
const ProductStoreCustom ProductStore = "custom"

type ProductSummary struct {
ValidatorsPerDashboardLimit uint64 `json:"validators_per_dashboard_limit"`
StripePublicKey string `json:"stripe_public_key"`
ApiProducts []ApiProduct `json:"api_products"`
PremiumProducts []PremiumProduct `json:"premium_products"`
Expand Down Expand Up @@ -108,7 +109,7 @@ type PremiumPerks struct {
CustomMachineAlerts bool `json:"custom_machine_alerts"`
}

// TODO @patrick StripeCreateCheckoutSession and StripeCustomerPortal are currently served from v1 (loadbalanced), Once V1 is not affected by this anymore, consider wrapping this with ApiDataResponse
// TODO @patrick post-beta StripeCreateCheckoutSession and StripeCustomerPortal are currently served from v1 (loadbalanced), Once V1 is not affected by this anymore, consider wrapping this with ApiDataResponse

type StripeCreateCheckoutSession struct {
SessionId string `json:"sessionId,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions frontend/types/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const ProductStoreAndroidPlaystore: ProductStore = "android-playstore";
export const ProductStoreEthpool: ProductStore = "ethpool";
export const ProductStoreCustom: ProductStore = "custom";
export interface ProductSummary {
validators_per_dashboard_limit: number /* uint64 */;
stripe_public_key: string;
api_products: ApiProduct[];
premium_products: PremiumProduct[];
Expand Down

0 comments on commit 4260130

Please sign in to comment.