Skip to content

Commit

Permalink
fixing copo & predictions bugs as filed
Browse files Browse the repository at this point in the history
  • Loading branch information
lleadbet committed Sep 7, 2021
1 parent 965a12c commit b2e09d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/database/channel_points_rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type ChannelPointsReward struct {
Cost int `db:"cost" json:"cost"`
Title string `db:"title" dbs:"cpr.title" json:"title"`
RewardPrompt string `db:"reward_prompt" json:"prompt"`
IsUserInputRequired bool `db:"is_user_input_required" json:"is_user_input_requird"`
IsUserInputRequired bool `db:"is_user_input_required" json:"is_user_input_required"`
MaxPerStream `json:"max_per_stream_setting"`
MaxPerUserPerStream `json:"max_per_user_per_stream_setting"`
GlobalCooldown `json:"global_cooldown_setting"`
Expand Down
8 changes: 6 additions & 2 deletions internal/events/types/prediction/prediction.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var transportsSupported = map[string]bool{
models.TransportEventSub: true,
}

var triggerSupported = []string{"prediction-begin", "prediction-progress", "prediction-end"}
var triggerSupported = []string{"prediction-begin", "prediction-progress", "prediction-end", "prediction-lock"}

var triggerMapping = map[string]map[string]string{
models.TransportEventSub: {
Expand Down Expand Up @@ -56,14 +56,15 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven

if params.Trigger != "prediction-begin" {
tp := []models.PredictionEventSubEventTopPredictors{}

sum := 0
for j := 0; j < int(util.RandomInt(10))+1; j++ {
t := models.PredictionEventSubEventTopPredictors{
UserID: util.RandomUserID(),
UserLogin: "testLogin",
UserName: "testLogin",
ChannelPointsUsed: int(util.RandomInt(10*1000)) + 100,
}
sum += t.ChannelPointsUsed
if params.Trigger == "prediction-lock" || params.Trigger == "prediction-end" {
if i == 0 {
t.ChannelPointsWon = intPointer(t.ChannelPointsUsed * 2)
Expand All @@ -74,6 +75,9 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven
tp = append(tp, t)
o.TopPredictors = &tp
}
length := len(*o.TopPredictors)
o.Users = &length
o.ChannelPoints = &sum
}

outcomes = append(outcomes, o)
Expand Down
2 changes: 1 addition & 1 deletion internal/mock_api/endpoints/channel_points/rewards.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type PatchAndPostRewardBody struct {
RewardPrompt string `json:"prompt"`
IsEnabled *bool `json:"is_enabled"`
BackgroundColor string `json:"background_color"`
IsUserInputRequired bool `json:"is_user_input_requird"`
IsUserInputRequired bool `json:"is_user_input_required"`
StreamMaxEnabled bool `json:"is_max_per_stream_enabled"`
StreamMaxCount int `json:"max_per_stream"`
StreamUserMaxEnabled bool `json:"is_max_per_user_per_stream_enabled"`
Expand Down

0 comments on commit b2e09d1

Please sign in to comment.