From ad5943ee3653b3cd5f305117a39c76de16e827fe Mon Sep 17 00:00:00 2001 From: Martin Purcell Date: Thu, 22 Jul 2021 18:13:24 +0100 Subject: [PATCH] fix: hype-train-progress and hype-train-end events were generating incorrect output --- .../events/types/hype_train/hype_train_event.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/events/types/hype_train/hype_train_event.go b/internal/events/types/hype_train/hype_train_event.go index c98e639e..1f6b6a44 100644 --- a/internal/events/types/hype_train/hype_train_event.go +++ b/internal/events/types/hype_train/hype_train_event.go @@ -39,6 +39,7 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven lastType := util.RandomType() //Local variables which will be used for the trigger params below + localLevel := util.RandomInt(5) localTotal := util.RandomInt(10 * 100) localGoal := util.RandomInt(10*100*100) + localTotal localProgress := (localTotal / localGoal) @@ -92,11 +93,20 @@ func (e Event) GenerateEvent(params events.MockEventParameters) (events.MockEven UserLoginWhoMadeContribution: "cli_user2", }, StartedAtTimestamp: util.GetTimestamp().Format(time.RFC3339Nano), - ExpiresAtTimestamp: util.GetTimestamp().Format(time.RFC3339Nano), + ExpiresAtTimestamp: util.GetTimestamp().Add(5 * time.Minute).Format(time.RFC3339Nano), }, } - if triggerMapping[params.Transport][params.Trigger] == "hype-train-end " { + if triggerMapping[params.Transport][params.Trigger] == "channel.hype_train.progress" { + body.Event.Level = localLevel + } + if triggerMapping[params.Transport][params.Trigger] == "channel.hype_train.end" { body.Event.CooldownEndsAtTimestamp = util.GetTimestamp().Add(1 * time.Hour).Format(time.RFC3339Nano) + body.Event.EndedAtTimestamp = util.GetTimestamp().Format(time.RFC3339Nano) + body.Event.ExpiresAtTimestamp = "" + body.Event.Goal = 0 + body.Event.Level = localLevel + body.Event.Progress = 0 + body.Event.StartedAtTimestamp = util.GetTimestamp().Add(5 * -time.Minute).Format(time.RFC3339Nano) } event, err = json.Marshal(body) if err != nil {