Skip to content

Commit

Permalink
feat: SeasonChallengeBuy + SeasonChallengeList + small fixes and refa…
Browse files Browse the repository at this point in the history
…ctors
  • Loading branch information
moul committed Nov 5, 2019
1 parent ce8348e commit 8743664
Show file tree
Hide file tree
Showing 23 changed files with 5,896 additions and 2,418 deletions.
57 changes: 41 additions & 16 deletions api/pwdb.proto
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,34 @@ message ChallengeFlavor {
Challenge challenge = 200 [(gogoproto.moretags) = "gorm:\"foreignkey:ChallengeID\""];
int64 challenge_id = 201 [(gogoproto.customname) = "ChallengeID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];

repeated ChallengeInstance instances = 202 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
repeated SeasonChallenge season_challenges = 202 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
//repeated ChallengeSubscription subscriptions = 203 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
}

message SeasonChallenge {
int64 id = 1 [(gogoproto.moretags) = "gorm:\"primary_key\"", (gogoproto.customname) = "ID"];
google.protobuf.Timestamp created_at = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
google.protobuf.Timestamp updated_at = 3 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
//google.protobuf.Timestamp deleted_at = 4 [(gogoproto.stdtime) = true];

//
// fields
//

//
// associations
//

ChallengeFlavor flavor = 200 [(gogoproto.moretags) = "gorm:\"foreignkey:FlavorID\""];
int64 flavor_id = 201 [(gogoproto.customname) = "FlavorID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];

Season season = 202 [(gogoproto.moretags) = "gorm:\"foreignkey:SeasonID\""];
int64 season_id = 203 [(gogoproto.customname) = "SeasonID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];

repeated ChallengeInstance instances = 204 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
repeated ChallengeSubscription subscriptions = 205 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
}

message ChallengeInstance {
int64 id = 1 [(gogoproto.moretags) = "gorm:\"primary_key\"", (gogoproto.customname) = "ID"];
google.protobuf.Timestamp created_at = 2 [(gogoproto.stdtime) = true, (gogoproto.nullable) = true];
Expand Down Expand Up @@ -221,10 +245,10 @@ message User {

repeated TeamMember team_memberships = 200 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
repeated Notification notifications = 201 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
repeated OrganizationMember memberships = 202 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
repeated OrganizationMember organization_memberships = 202 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
TeamMember active_team_member = 203 [(gogoproto.moretags) = "gorm:\"foreignkey:ActiveTeamMemberID;PRELOAD:false\""];
int64 active_team_member_id = 204 [(gogoproto.customname) = "ActiveTeamMemberID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
TeamMember active_season = 205 [(gogoproto.moretags) = "gorm:\"foreignkey:ActiveSeasonID;PRELOAD:false\""];
Season active_season = 205 [(gogoproto.moretags) = "gorm:\"foreignkey:ActiveSeasonID;PRELOAD:false\""];
int64 active_season_id = 206 [(gogoproto.customname) = "ActiveSeasonID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
}

Expand Down Expand Up @@ -379,8 +403,8 @@ message ChallengeValidation {

ChallengeSubscription challenge_subscription = 200 [(gogoproto.moretags) = "gorm:\"foreignkey:ChallengeSubscriptionID\""];
int64 challenge_subscription_id = 201 [(gogoproto.customname) = "ChallengeSubscriptionID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
TeamMember team_member = 202 [(gogoproto.moretags) = "gorm:\"foreignkey:TeamMemberID\""];
int64 team_member_id = 203 [(gogoproto.customname) = "TeamMemberID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
TeamMember author = 202 [(gogoproto.moretags) = "gorm:\"foreignkey:AuthorID\""];
int64 author_id = 203 [(gogoproto.customname) = "AuthorID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
}

message ChallengeSubscription {
Expand All @@ -398,10 +422,10 @@ message ChallengeSubscription {
//

Team team = 200 [(gogoproto.moretags) = "gorm:\"foreignkey:TeamID\""];
int64 team_id = 201 [(gogoproto.customname) = "TeamID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
int64 team_id = 201 [(gogoproto.customname) = "TeamID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"unique_index:idx_team_season_challenge\""];

ChallengeFlavor challenge_flavor = 202 [(gogoproto.moretags) = "gorm:\"foreignkey:ChallengeFlavorID\""];
int64 challenge_flavor_id = 203 [(gogoproto.customname) = "ChallengeFlavorID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"index\""];
SeasonChallenge season_challenge = 202 [(gogoproto.moretags) = "gorm:\"foreignkey:SeasonChallengeID\""];
int64 season_challenge_id = 203 [(gogoproto.customname) = "SeasonChallengeID", (gogoproto.moretags) = "sql:\"not null\" gorm:\"unique_index:idx_team_season_challenge\""];

repeated ChallengeValidation validations = 204 [(gogoproto.moretags) = "gorm:\"PRELOAD:false\""];
}
Expand Down Expand Up @@ -582,14 +606,15 @@ message Dump {
repeated ChallengeInstance challenge_instances = 4;
repeated ChallengeSubscription challenge_subscriptions = 5;
repeated ChallengeValidation challenge_validations = 6;
repeated Coupon coupons = 8;
repeated CouponValidation coupon_validations = 9;
repeated Hypervisor hypervisors = 10;
repeated InventoryItem inventory_items = 11;
repeated Notification notifications = 12;
repeated Organization organizations = 13;
repeated OrganizationMember organization_members = 14;
repeated Season seasons = 15;
repeated Coupon coupons = 7;
repeated CouponValidation coupon_validations = 8;
repeated Hypervisor hypervisors = 9;
repeated InventoryItem inventory_items = 10;
repeated Notification notifications = 11;
repeated Organization organizations = 12;
repeated OrganizationMember organization_members = 13;
repeated Season seasons = 14;
repeated SeasonChallenge season_challenges = 15;
repeated Team teams = 16;
repeated TeamMember team_members = 17;
repeated User users = 18;
Expand Down
23 changes: 23 additions & 0 deletions api/pwengine.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ service Engine {

rpc ChallengeList(ChallengeListInput) returns (ChallengeListOutput) { option (google.api.http) = {get: "/challenges"}; };
rpc ChallengeGet(ChallengeGetInput) returns (ChallengeGetOutput) { option (google.api.http) = {get: "/challenge"}; };
rpc SeasonChallengeList(SeasonChallengeListInput) returns (SeasonChallengeListOutput) { option (google.api.http) = {get: "/season-challenges"}; };
rpc SeasonChallengeGet(SeasonChallengeGetInput) returns (SeasonChallengeGetOutput) { option (google.api.http) = {get: "/season-challenge"}; };
rpc SeasonChallengeBuy(SeasonChallengeBuyInput) returns (SeasonChallengeBuyOutput) { option (google.api.http) = {post: "/challenge/buy"; body: "*"}; };
rpc ChallengeSubscriptionValidate(ChallengeSubscriptionValidateInput) returns (ChallengeSubscriptionValidateOutput) { option (google.api.http) = {post: "/challenge/validate"; body: "*"}; };
rpc ChallengeSubscriptionClose(ChallengeSubscriptionCloseInput) returns (ChallengeSubscriptionCloseOutput) { option (google.api.http) = {post: "/challenge/close"; body: "*"}; };

//
// Organization
Expand Down Expand Up @@ -61,9 +66,27 @@ service Engine {
message TeamGetInput { int64 team_id = 1 [(gogoproto.customname) = "TeamID"]; }
message TeamGetOutput { pathwar.db.Team item = 1; }

message SeasonChallengeListInput { int64 season_id = 1 [(gogoproto.customname) = "SeasonID"]; }
message SeasonChallengeListOutput { repeated pathwar.db.SeasonChallenge items = 1; }

message SeasonChallengeGetInput { int64 season_challenge_id = 1 [(gogoproto.customname) = "SeasonChallengeID"]; }
message SeasonChallengeGetOutput { pathwar.db.SeasonChallenge item = 1; }

message ChallengeGetInput { int64 challenge_id = 1 [(gogoproto.customname) = "ChallengeID"]; }
message ChallengeGetOutput { pathwar.db.Challenge item = 1; }

message SeasonChallengeBuyInput {
int64 season_challenge_id = 1 [(gogoproto.customname) = "SeasonChallengeID"];
int64 team_id = 2 [(gogoproto.customname) = "TeamID"];
}
message SeasonChallengeBuyOutput { pathwar.db.ChallengeSubscription challenge_subscription = 1; }

message ChallengeSubscriptionValidateInput { int64 challenge_subscription_id = 1 [(gogoproto.customname) = "ChallengeSubscriptionID"]; }
message ChallengeSubscriptionValidateOutput {}

message ChallengeSubscriptionCloseInput { int64 challenge_subscription_id = 1 [(gogoproto.customname) = "ChallengeSubscriptionID"]; }
message ChallengeSubscriptionCloseOutput {}

message TeamListInput { int64 season_id = 1 [(gogoproto.customname) = "SeasonID"]; }
message TeamListOutput { repeated pathwar.db.Team items = 1; }

Expand Down
4 changes: 2 additions & 2 deletions docs/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions go/gen.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions go/pkg/pwdb/entity.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ func AllMap() map[string]interface{} {
"Organization": Organization{},
"OrganizationMember": OrganizationMember{},
"Season": Season{},
"TeamMember": TeamMember{},
"SeasonChallenge": SeasonChallenge{},
"Team": Team{},
"TeamMember": TeamMember{},
"User": User{},
"WhoswhoAttempt": WhoswhoAttempt{},
}
Expand All @@ -43,21 +44,23 @@ func ForeignKeys() [][3]string {
{"ChallengeFlavor", "challenge_id", "challenge(id)"},
{"ChallengeInstance", "flavor_id", "challenge_flavor(id)"},
{"ChallengeInstance", "hypervisor_id", "hypervisor(id)"},
{"ChallengeSubscription", "challenge_flavor_id", "challenge_flavor(id)"},
{"ChallengeSubscription", "season_challenge_id", "season_challenge(id)"},
{"ChallengeSubscription", "team_id", "team(id)"},
{"ChallengeValidation", "challenge_subscription_id", "challenge_subscription(id)"},
{"ChallengeValidation", "team_member_id", "team_member(id)"},
{"ChallengeValidation", "author_id", "team_member(id)"},
{"Coupon", "season_id", "season(id)"},
{"CouponValidation", "author_id", "team_member(id)"},
{"CouponValidation", "coupon_id", "coupon(id)"},
{"InventoryItem", "owner_id", "team_member(id)"},
{"Notification", "user_id", "user(id)"},
{"OrganizationMember", "organization_id", "organization(id)"},
{"OrganizationMember", "user_id", "user(id)"},
{"TeamMember", "team_id", "team(id)"},
{"TeamMember", "user_id", "user(id)"},
{"SeasonChallenge", "flavor_id", "challenge_flavor(id)"},
{"SeasonChallenge", "season_id", "season(id)"},
{"Team", "organization_id", "organization(id)"},
{"Team", "season_id", "season(id)"},
{"TeamMember", "team_id", "team(id)"},
{"TeamMember", "user_id", "user(id)"},
{"WhoswhoAttempt", "author_id", "team_member(id)"},
{"WhoswhoAttempt", "target_member_id", "team_member(id)"},
{"WhoswhoAttempt", "target_organization_id", "team(id)"},
Expand Down
Loading

0 comments on commit 8743664

Please sign in to comment.