diff --git a/api/go.mod b/api/go.mod index dccf52d..0a6cc74 100644 --- a/api/go.mod +++ b/api/go.mod @@ -1,6 +1,6 @@ module github.com/ashleyjlive/entain/api -go 1.16 +go 1.17 require ( github.com/grpc-ecosystem/grpc-gateway/v2 v2.5.0 @@ -13,3 +13,13 @@ require ( gopkg.in/yaml.v2 v2.3.0 // indirect gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect ) + +require ( + github.com/ghodss/yaml v1.0.0 // indirect + github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/magefile/mage v1.10.0 // indirect + golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/text v0.3.5 // indirect +) diff --git a/api/proto/racing/racing.pb.go b/api/proto/racing/racing.pb.go index 9105676..d60096a 100644 --- a/api/proto/racing/racing.pb.go +++ b/api/proto/racing/racing.pb.go @@ -22,6 +22,52 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Race_Status int32 + +const ( + Race_CLOSED Race_Status = 0 + Race_OPEN Race_Status = 1 +) + +// Enum value maps for Race_Status. +var ( + Race_Status_name = map[int32]string{ + 0: "CLOSED", + 1: "OPEN", + } + Race_Status_value = map[string]int32{ + "CLOSED": 0, + "OPEN": 1, + } +) + +func (x Race_Status) Enum() *Race_Status { + p := new(Race_Status) + *p = x + return p +} + +func (x Race_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Race_Status) Descriptor() protoreflect.EnumDescriptor { + return file_racing_racing_proto_enumTypes[0].Descriptor() +} + +func (Race_Status) Type() protoreflect.EnumType { + return &file_racing_racing_proto_enumTypes[0] +} + +func (x Race_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Race_Status.Descriptor instead. +func (Race_Status) EnumDescriptor() ([]byte, []int) { + return file_racing_racing_proto_rawDescGZIP(), []int{3, 0} +} + // Request for ListRaces call. type ListRacesRequest struct { state protoimpl.MessageState @@ -200,6 +246,7 @@ type Race struct { Visible bool `protobuf:"varint,5,opt,name=visible,proto3" json:"visible,omitempty"` // AdvertisedStartTime is the time the race is advertised to run. AdvertisedStartTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=advertised_start_time,json=advertisedStartTime,proto3" json:"advertised_start_time,omitempty"` + Status Race_Status `protobuf:"varint,7,opt,name=status,proto3,enum=racing.Race_Status" json:"status,omitempty"` } func (x *Race) Reset() { @@ -276,6 +323,13 @@ func (x *Race) GetAdvertisedStartTime() *timestamppb.Timestamp { return nil } +func (x *Race) GetStatus() Race_Status { + if x != nil { + return x.Status + } + return Race_CLOSED +} + var File_racing_racing_proto protoreflect.FileDescriptor var file_racing_racing_proto_rawDesc = []byte{ @@ -302,7 +356,7 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, 0x69, 0x73, - 0x69, 0x62, 0x6c, 0x65, 0x22, 0xcb, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, + 0x69, 0x62, 0x6c, 0x65, 0x22, 0x98, 0x02, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, @@ -315,14 +369,19 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, 0x54, 0x69, - 0x6d, 0x65, 0x32, 0x65, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, - 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, - 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, - 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, - 0x82, 0xd3, 0xe4, 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, - 0x2d, 0x72, 0x61, 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, - 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, 0x20, 0x01, + 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, 0x63, 0x65, + 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, + 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, 0x06, 0x43, 0x4c, 0x4f, + 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, 0x01, 0x32, + 0x65, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x5b, 0x0a, 0x09, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, + 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, + 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x19, 0x82, 0xd3, 0xe4, + 0x93, 0x02, 0x13, 0x22, 0x0e, 0x2f, 0x76, 0x31, 0x2f, 0x6c, 0x69, 0x73, 0x74, 0x2d, 0x72, 0x61, + 0x63, 0x65, 0x73, 0x3a, 0x01, 0x2a, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, + 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -337,25 +396,28 @@ func file_racing_racing_proto_rawDescGZIP() []byte { return file_racing_racing_proto_rawDescData } +var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_racing_racing_proto_goTypes = []interface{}{ - (*ListRacesRequest)(nil), // 0: racing.ListRacesRequest - (*ListRacesResponse)(nil), // 1: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 2: racing.ListRacesRequestFilter - (*Race)(nil), // 3: racing.Race - (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp + (Race_Status)(0), // 0: racing.Race.Status + (*ListRacesRequest)(nil), // 1: racing.ListRacesRequest + (*ListRacesResponse)(nil), // 2: racing.ListRacesResponse + (*ListRacesRequestFilter)(nil), // 3: racing.ListRacesRequestFilter + (*Race)(nil), // 4: racing.Race + (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 2, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 3, // 1: racing.ListRacesResponse.races:type_name -> racing.Race - 4, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp - 0, // 3: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 1, // 4: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 3, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 4, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 5, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 0, // 3: racing.Race.status:type_name -> racing.Race.Status + 1, // 4: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest + 2, // 5: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 5, // [5:6] is the sub-list for method output_type + 4, // [4:5] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_racing_racing_proto_init() } @@ -420,13 +482,14 @@ func file_racing_racing_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 4, NumExtensions: 0, NumServices: 1, }, GoTypes: file_racing_racing_proto_goTypes, DependencyIndexes: file_racing_racing_proto_depIdxs, + EnumInfos: file_racing_racing_proto_enumTypes, MessageInfos: file_racing_racing_proto_msgTypes, }.Build() File_racing_racing_proto = out.File diff --git a/api/proto/racing/racing.proto b/api/proto/racing/racing.proto index 1d0d1c2..3075bf7 100644 --- a/api/proto/racing/racing.proto +++ b/api/proto/racing/racing.proto @@ -50,4 +50,11 @@ message Race { bool visible = 5; // AdvertisedStartTime is the time the race is advertised to run. google.protobuf.Timestamp advertised_start_time = 6; + enum Status { + CLOSED = 0; + OPEN = 1; + } + // Status reflects whether the Race is open or closed, based off the + // advertised start time being in the past. + Status status = 7; } diff --git a/racing/db/db.go b/racing/db/db.go index 272fdf3..df7e257 100644 --- a/racing/db/db.go +++ b/racing/db/db.go @@ -6,6 +6,7 @@ import ( "github.com/ashleyjlive/entain/racing/proto/racing" "github.com/golang/protobuf/ptypes" + "google.golang.org/protobuf/types/known/timestamppb" "syreclabs.com/go/faker" ) @@ -58,10 +59,7 @@ func (r *racesRepo) listAll() ([]*racing.Race, error) { return nil, err } - ts, err := ptypes.TimestampProto(advertisedStart) - if err != nil { - return nil, err - } + ts := timestamppb.New(advertisedStart) race.AdvertisedStartTime = ts diff --git a/racing/db/races.go b/racing/db/races.go index 7960fca..4c84ac5 100644 --- a/racing/db/races.go +++ b/racing/db/races.go @@ -8,8 +8,8 @@ import ( "time" "unicode" - "github.com/golang/protobuf/ptypes" _ "github.com/mattn/go-sqlite3" + "google.golang.org/protobuf/types/known/timestamppb" "github.com/ashleyjlive/entain/racing/proto/racing" ) @@ -154,16 +154,16 @@ func toOrderBySql(input string) (*string, error) { words := strings.Fields(str) wordCount := len(words) if wordCount > 2 || wordCount < 1 { - return nil, errors.New("Invalid order by term count.") + return nil, errors.New("invalid order by term count") } sortField := words[0] if strings.IndexFunc(sortField, isUnsafeColumnChar) != -1 { - return nil, errors.New("Invalid column name.") + return nil, errors.New("invalid column name") } if wordCount == 2 { sort := words[1] if !(strings.EqualFold(sort, "asc") || strings.EqualFold(sort, "desc")) { - return nil, errors.New("Invalid order by dir parameter.") + return nil, errors.New("invalid order by dir parameter") } sortField += " " + sort } @@ -203,11 +203,16 @@ func (m *racesRepo) scanRaces( return nil, err } - ts, err := ptypes.TimestampProto(advertisedStart) - if err != nil { - return nil, err - } + ts := timestamppb.New(advertisedStart) + if advertisedStart.Before(time.Now()) { + // All races that have an `advertised_start_time` in the past should + // reflect `CLOSED` + // Note that this depends on the system having the correct time. + race.Status = racing.Race_CLOSED + } else { + race.Status = racing.Race_OPEN + } race.AdvertisedStartTime = ts races = append(races, &race) diff --git a/racing/db/races_test.go b/racing/db/races_test.go index 4eb3e85..864ee11 100644 --- a/racing/db/races_test.go +++ b/racing/db/races_test.go @@ -10,8 +10,9 @@ import ( "github.com/ashleyjlive/entain/racing/db" "github.com/ashleyjlive/entain/racing/proto/racing" - "github.com/golang/protobuf/ptypes" "syreclabs.com/go/faker" + + "google.golang.org/protobuf/types/known/timestamppb" ) func TestRepo(t *testing.T) { @@ -183,7 +184,7 @@ func TestOrderBy(t *testing.T) { racesRepo := db.NewRacesRepo(racingDB) _ = racesRepo.Init(false) - tm1, _ := ptypes.TimestampProto(time.Now().AddDate(0, 0, 2)) + tm1 := timestamppb.New(time.Now().AddDate(0, 0, 2)) race1 := racing.Race{Id: int64(1), MeetingId: int64(5), Name: "Test1", Number: int64(5), @@ -192,7 +193,7 @@ func TestOrderBy(t *testing.T) { if err != nil { t.Fatalf("Failed to insert first race %v.", err) } - tm2, _ := ptypes.TimestampProto(time.Now().AddDate(0, 0, 2)) + tm2 := timestamppb.New(time.Now().AddDate(0, 0, -2)) race2 := racing.Race{Id: int64(5), MeetingId: int64(3), Name: "Test2", Number: int64(9), @@ -259,6 +260,50 @@ func TestOrderBy(t *testing.T) { } } +func TestStatusField(t *testing.T) { + racingDB, err := GetTestDB("races", "TestStatusField") + if err != nil { + t.Fatalf("Failed to open testdb %v", err) + } + racesRepo := db.NewRacesRepo(racingDB) + _ = racesRepo.Init(false) + + tm1 := timestamppb.New(time.Now().AddDate(0, 0, 2)) + race1 := + racing.Race{Id: int64(1), MeetingId: int64(5), + Name: "Test1", Number: int64(5), + Visible: true, AdvertisedStartTime: tm1} + err = racesRepo.InsertRace(&race1) + if err != nil { + t.Fatalf("Failed to insert first race %v.", err) + } + tm2 := timestamppb.New(time.Now().AddDate(0, 0, -2)) + race2 := + racing.Race{Id: int64(5), MeetingId: int64(3), + Name: "Test2", Number: int64(9), + Visible: false, AdvertisedStartTime: tm2} + err = racesRepo.InsertRace(&race2) + if err != nil { + t.Fatalf("Failed to insert second race %v.", err) + } + + // Test case + rq := racing.ListRacesRequest{} + rsp, err := racesRepo.List(&rq) + if err != nil { + t.Fatalf("Unable to retrieve races list.") + } + if len(rsp) != 2 { + t.Fatalf("Returned incorrect amount of races.") + } + if rsp[0].Status != racing.Race_CLOSED { + t.Fatalf("Returned invalid status flag for closed event %v.", rsp[0].Id) + } + if rsp[1].Status != racing.Race_OPEN { + t.Fatalf("Returned invalid status flag for open event %v.", rsp[1].Id) + } +} + // Helpers // func GetRaces() []*racing.Race { @@ -270,7 +315,7 @@ func GetRaces() []*racing.Race { name := faker.Team().Name() number, _ := strconv.Atoi(faker.Number().Between(1, 12)) visible := randBool() - tm, _ := ptypes.TimestampProto( + tm := timestamppb.New( faker.Time().Between( time.Now().AddDate(0, 0, -1), time.Now().AddDate(0, 0, 2))) race := diff --git a/racing/go.mod b/racing/go.mod index 63cca47..e0f69d0 100644 --- a/racing/go.mod +++ b/racing/go.mod @@ -1,6 +1,6 @@ module github.com/ashleyjlive/entain/racing -go 1.16 +go 1.17 require ( github.com/golang/protobuf v1.5.2 @@ -17,3 +17,11 @@ require ( gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect syreclabs.com/go/faker v1.2.3 ) + +require ( + github.com/ghodss/yaml v1.0.0 // indirect + github.com/golang/glog v0.0.0-20210429001901-424d2337a529 // indirect + github.com/magefile/mage v1.10.0 // indirect + golang.org/x/sys v0.0.0-20210510120138-977fb7262007 // indirect + golang.org/x/text v0.3.5 // indirect +) diff --git a/racing/proto/README.md b/racing/proto/README.md index f6821c7..e7d0c5e 100644 --- a/racing/proto/README.md +++ b/racing/proto/README.md @@ -23,4 +23,5 @@ This defines the protobuf message types for the racing API. - The unique identifier for the races meeting (int64). - The name of the race (string). - The visibility of the race (bool). -- The advertised start time of the race (Timestamp). \ No newline at end of file +- The advertised start time of the race (Timestamp). +- A status flag indicating if the event is `OPEN` or `CLOSED` - this is based off the advertised start time with the systems current time. \ No newline at end of file diff --git a/racing/proto/racing/racing.pb.go b/racing/proto/racing/racing.pb.go index a2b9a68..02495d3 100644 --- a/racing/proto/racing/racing.pb.go +++ b/racing/proto/racing/racing.pb.go @@ -21,6 +21,52 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +type Race_Status int32 + +const ( + Race_CLOSED Race_Status = 0 + Race_OPEN Race_Status = 1 +) + +// Enum value maps for Race_Status. +var ( + Race_Status_name = map[int32]string{ + 0: "CLOSED", + 1: "OPEN", + } + Race_Status_value = map[string]int32{ + "CLOSED": 0, + "OPEN": 1, + } +) + +func (x Race_Status) Enum() *Race_Status { + p := new(Race_Status) + *p = x + return p +} + +func (x Race_Status) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (Race_Status) Descriptor() protoreflect.EnumDescriptor { + return file_racing_racing_proto_enumTypes[0].Descriptor() +} + +func (Race_Status) Type() protoreflect.EnumType { + return &file_racing_racing_proto_enumTypes[0] +} + +func (x Race_Status) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use Race_Status.Descriptor instead. +func (Race_Status) EnumDescriptor() ([]byte, []int) { + return file_racing_racing_proto_rawDescGZIP(), []int{3, 0} +} + type ListRacesRequest struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -198,6 +244,7 @@ type Race struct { Visible bool `protobuf:"varint,5,opt,name=visible,proto3" json:"visible,omitempty"` // AdvertisedStartTime is the time the race is advertised to run. AdvertisedStartTime *timestamppb.Timestamp `protobuf:"bytes,6,opt,name=advertised_start_time,json=advertisedStartTime,proto3" json:"advertised_start_time,omitempty"` + Status Race_Status `protobuf:"varint,7,opt,name=status,proto3,enum=racing.Race_Status" json:"status,omitempty"` } func (x *Race) Reset() { @@ -274,6 +321,13 @@ func (x *Race) GetAdvertisedStartTime() *timestamppb.Timestamp { return nil } +func (x *Race) GetStatus() Race_Status { + if x != nil { + return x.Status + } + return Race_CLOSED +} + var File_racing_racing_proto protoreflect.FileDescriptor var file_racing_racing_proto_rawDesc = []byte{ @@ -298,7 +352,7 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x73, 0x12, 0x1d, 0x0a, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x48, 0x00, 0x52, 0x07, 0x76, 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x88, 0x01, 0x01, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x76, - 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x22, 0xcb, 0x01, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, + 0x69, 0x73, 0x69, 0x62, 0x6c, 0x65, 0x22, 0x98, 0x02, 0x0a, 0x04, 0x52, 0x61, 0x63, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6d, 0x65, 0x65, 0x74, 0x69, 0x6e, 0x67, 0x49, 0x64, 0x12, 0x12, @@ -311,13 +365,18 @@ var file_racing_racing_proto_rawDesc = []byte{ 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x13, 0x61, 0x64, 0x76, 0x65, 0x72, 0x74, 0x69, 0x73, 0x65, 0x64, 0x53, 0x74, 0x61, 0x72, 0x74, - 0x54, 0x69, 0x6d, 0x65, 0x32, 0x4c, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x42, - 0x0a, 0x09, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, - 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, - 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, - 0x22, 0x00, 0x42, 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2b, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x0e, 0x32, 0x13, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x52, 0x61, + 0x63, 0x65, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, + 0x73, 0x22, 0x1e, 0x0a, 0x06, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0a, 0x0a, 0x06, 0x43, + 0x4c, 0x4f, 0x53, 0x45, 0x44, 0x10, 0x00, 0x12, 0x08, 0x0a, 0x04, 0x4f, 0x50, 0x45, 0x4e, 0x10, + 0x01, 0x32, 0x4c, 0x0a, 0x06, 0x52, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x12, 0x42, 0x0a, 0x09, 0x4c, + 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x12, 0x18, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, + 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x1a, 0x19, 0x2e, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x2e, 0x4c, 0x69, 0x73, 0x74, + 0x52, 0x61, 0x63, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, + 0x09, 0x5a, 0x07, 0x2f, 0x72, 0x61, 0x63, 0x69, 0x6e, 0x67, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -332,25 +391,28 @@ func file_racing_racing_proto_rawDescGZIP() []byte { return file_racing_racing_proto_rawDescData } +var file_racing_racing_proto_enumTypes = make([]protoimpl.EnumInfo, 1) var file_racing_racing_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_racing_racing_proto_goTypes = []interface{}{ - (*ListRacesRequest)(nil), // 0: racing.ListRacesRequest - (*ListRacesResponse)(nil), // 1: racing.ListRacesResponse - (*ListRacesRequestFilter)(nil), // 2: racing.ListRacesRequestFilter - (*Race)(nil), // 3: racing.Race - (*timestamppb.Timestamp)(nil), // 4: google.protobuf.Timestamp + (Race_Status)(0), // 0: racing.Race.Status + (*ListRacesRequest)(nil), // 1: racing.ListRacesRequest + (*ListRacesResponse)(nil), // 2: racing.ListRacesResponse + (*ListRacesRequestFilter)(nil), // 3: racing.ListRacesRequestFilter + (*Race)(nil), // 4: racing.Race + (*timestamppb.Timestamp)(nil), // 5: google.protobuf.Timestamp } var file_racing_racing_proto_depIdxs = []int32{ - 2, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter - 3, // 1: racing.ListRacesResponse.races:type_name -> racing.Race - 4, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp - 0, // 3: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest - 1, // 4: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse - 4, // [4:5] is the sub-list for method output_type - 3, // [3:4] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 3, // 0: racing.ListRacesRequest.filter:type_name -> racing.ListRacesRequestFilter + 4, // 1: racing.ListRacesResponse.races:type_name -> racing.Race + 5, // 2: racing.Race.advertised_start_time:type_name -> google.protobuf.Timestamp + 0, // 3: racing.Race.status:type_name -> racing.Race.Status + 1, // 4: racing.Racing.ListRaces:input_type -> racing.ListRacesRequest + 2, // 5: racing.Racing.ListRaces:output_type -> racing.ListRacesResponse + 5, // [5:6] is the sub-list for method output_type + 4, // [4:5] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name } func init() { file_racing_racing_proto_init() } @@ -415,13 +477,14 @@ func file_racing_racing_proto_init() { File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_racing_racing_proto_rawDesc, - NumEnums: 0, + NumEnums: 1, NumMessages: 4, NumExtensions: 0, NumServices: 1, }, GoTypes: file_racing_racing_proto_goTypes, DependencyIndexes: file_racing_racing_proto_depIdxs, + EnumInfos: file_racing_racing_proto_enumTypes, MessageInfos: file_racing_racing_proto_msgTypes, }.Build() File_racing_racing_proto = out.File diff --git a/racing/proto/racing/racing.proto b/racing/proto/racing/racing.proto index 44d1479..892a858 100644 --- a/racing/proto/racing/racing.proto +++ b/racing/proto/racing/racing.proto @@ -46,5 +46,12 @@ message Race { bool visible = 5; // AdvertisedStartTime is the time the race is advertised to run. google.protobuf.Timestamp advertised_start_time = 6; + enum Status { + CLOSED = 0; + OPEN = 1; + } + // Status reflects whether the Race is open or closed, based off the + // advertised start time being in the past. + Status status = 7; }