syntax = "proto3";

package hype_train;

option go_package = "hype_train";

import "eventbus/change.proto";
import "eventbus/owner.proto";
import "google/protobuf/timestamp.proto";
import "hype_train/create.proto";

// HypeTrainUpdate is triggered when hype train progress is made on a channel.
message HypeTrainUpdate {
  option (eventbus.owner.ldap_group) = "team-commerce";
  // The id of the hype train.
  string id = 1;
  // The user id of the broadcaster.
  string broadcaster_user_id = 2;
  // The current level.
  eventbus.change.Int64Change level = 3;
  // The total points contributed.
  eventbus.change.Int64Change total = 4;
  // The number of points required to reach the next level.
  eventbus.change.Int64Change goal = 5;
  // The most recent contribution.
  ContributionChange last_contribution = 6;
  // The contributors with the most points contributed.
  repeated ContributionChange top_contributions = 7;
  // The time at which the hype train started.
  google.protobuf.Timestamp started_at = 8;
  // The time at which the hype train expires. The expiration is extended when
  // the hype train reaches a new level.
  eventbus.change.TimestampChange expires_at = 9;
  // The number of points accumulated for the current level only.
  eventbus.change.Int64Change progress = 10;
}

// ContributionChange represents a changed contribution and follows the 'change.proto' scheme.
message ContributionChange {
  bool updated = 1;
  Contribution value = 2;
  bool has_old_value = 3;
  Contribution old_value = 4;
}
