Skip to content

Commit

Permalink
(BEDS-425) remove environment query param
Browse files Browse the repository at this point in the history
  • Loading branch information
LuccaBitfly committed Sep 10, 2024
1 parent c398c9a commit e0594f4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 45 deletions.
7 changes: 3 additions & 4 deletions backend/pkg/api/data_access/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"
"time"

"github.com/gobitfly/beaconchain/pkg/api/enums"
t "github.com/gobitfly/beaconchain/pkg/api/types"
"github.com/gobitfly/beaconchain/pkg/commons/utils"
"github.com/gobitfly/beaconchain/pkg/userservice"
Expand All @@ -21,7 +20,7 @@ type AppRepository interface {
AddMobileNotificationToken(userID uint64, deviceID, notifyToken string) error
GetAppSubscriptionCount(userID uint64) (uint64, error)
AddMobilePurchase(tx *sql.Tx, userID uint64, paymentDetails t.MobileSubscription, verifyResponse *userservice.VerifyResponse, extSubscriptionId string) error
GetLatestBundleForNativeVersion(ctx context.Context, nativeVersion uint64, environment enums.Environment) (*t.MobileAppBundleStats, error)
GetLatestBundleForNativeVersion(ctx context.Context, nativeVersion uint64) (*t.MobileAppBundleStats, error)
IncrementBundleDeliveryCount(ctx context.Context, bundleVerison uint64) error
}

Expand Down Expand Up @@ -110,9 +109,9 @@ func (d *DataAccessService) AddMobilePurchase(tx *sql.Tx, userID uint64, payment
return err
}

func (d *DataAccessService) GetLatestBundleForNativeVersion(ctx context.Context, nativeVersion uint64, environment enums.Environment) (*t.MobileAppBundleStats, error) {
func (d *DataAccessService) GetLatestBundleForNativeVersion(ctx context.Context, nativeVersion uint64) (*t.MobileAppBundleStats, error) {
// @TODO data access
return d.dummy.GetLatestBundleForNativeVersion(ctx, nativeVersion, environment)
return d.dummy.GetLatestBundleForNativeVersion(ctx, nativeVersion)
}

func (d *DataAccessService) IncrementBundleDeliveryCount(ctx context.Context, bundleVerison uint64) error {
Expand Down
7 changes: 3 additions & 4 deletions backend/pkg/api/data_access/dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/go-faker/faker/v4"
"github.com/go-faker/faker/v4/pkg/options"
"github.com/gobitfly/beaconchain/pkg/api/enums"
"github.com/gobitfly/beaconchain/pkg/api/types"
t "github.com/gobitfly/beaconchain/pkg/api/types"
"github.com/gobitfly/beaconchain/pkg/userservice"
"github.com/shopspring/decimal"
Expand Down Expand Up @@ -637,12 +636,12 @@ func (d *DummyService) GetRocketPoolOverview(ctx context.Context) (*t.RocketPool
return getDummyStruct[t.RocketPoolData]()
}

func (d *DummyService) GetHealthz(ctx context.Context, showAll bool) types.HealthzData {
r, _ := getDummyData[types.HealthzData]()
func (d *DummyService) GetHealthz(ctx context.Context, showAll bool) t.HealthzData {
r, _ := getDummyData[t.HealthzData]()
return r
}

func (d *DummyService) GetLatestBundleForNativeVersion(ctx context.Context, nativeVersion uint64, environment enums.Environment) (*t.MobileAppBundleStats, error) {
func (d *DummyService) GetLatestBundleForNativeVersion(ctx context.Context, nativeVersion uint64) (*t.MobileAppBundleStats, error) {
return getDummyStruct[t.MobileAppBundleStats]()
}

Expand Down
35 changes: 0 additions & 35 deletions backend/pkg/api/enums/enums.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,38 +268,3 @@ func (c ChartAggregation) Duration(secondsPerEpoch uint64) time.Duration {
return 0
}
}

// ----------------
// Environment

type Environment int

var _ EnumFactory[Environment] = Environment(0)

const (
EnvironmentProduction Environment = iota
EnvironmentStaging
)

func (e Environment) Int() int {
return int(e)
}

func (Environment) NewFromString(s string) Environment {
switch s {
case "production", "prod", "":
return EnvironmentProduction
case "staging":
return EnvironmentStaging
default:
return Environment(-1)
}
}

var Environments = struct {
Production Environment
Staging Environment
}{
EnvironmentProduction,
EnvironmentStaging,
}
3 changes: 1 addition & 2 deletions backend/pkg/api/handlers/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,11 @@ func (h *HandlerService) InternalGetMobileLatestBundle(w http.ResponseWriter, r
force := v.checkBool(q.Get("force"), "force")
bundleVersion := v.checkUint(q.Get("bundle_version"), "bundle_version")
nativeVersion := v.checkUint(q.Get("native_version"), "native_version")
environment := checkEnum[enums.Environment](&v, q.Get("environment"), "environment")
if v.hasErrors() {
handleErr(w, r, v)
return
}
stats, err := h.dai.GetLatestBundleForNativeVersion(r.Context(), nativeVersion, environment)
stats, err := h.dai.GetLatestBundleForNativeVersion(r.Context(), nativeVersion)
if err != nil {
handleErr(w, r, err)
return
Expand Down

0 comments on commit e0594f4

Please sign in to comment.