diff --git a/api/proto/auth.proto b/api/proto/auth.proto index 9e07990..cdd9b6b 100644 --- a/api/proto/auth.proto +++ b/api/proto/auth.proto @@ -6,10 +6,7 @@ option go_package = "pkg/api/auth"; service AuthService { rpc SignUp(SignUpRequest) returns (SignUpResponse); rpc SignIn(SignInRequest) returns (SignInResponse); - rpc GetMe(GetMeRequest) returns (GetMeResponse); - rpc GetUser(GetUserRequest) returns (GetUserResponse); - rpc GetMyStat(GetMyStatRequest) returns (GetMyStatResponse); - rpc GetLeaderboard(GetLeaderboardRequest) returns (GetLeaderboardResponse); + rpc ValidateToken(ValidateTokenRequest) returns (ValidateTokenResponse); } message SignUpRequest { @@ -29,46 +26,9 @@ message SignInResponse { string token = 1; } -message GetMeRequest {} -message GetMeResponse { - User user = 1; +message ValidateTokenRequest { + string token = 1; } - -message GetUserRequest { +message ValidateTokenResponse { string user_id = 1; } -message GetUserResponse { - User user = 1; -} - -message GetMyStatRequest {} -message GetMyStatResponse { - Stat stat = 1; -} - -message GetLeaderboardRequest {} -message GetLeaderboardResponse { - repeated User users = 1; -} - -message User { - optional string id = 1; - string email = 2; - string username = 3; - optional string avatar = 4; - string created_at = 5; - repeated UserAchievement achievements = 6; -} - -message UserAchievement { - string name = 1; - string description = 2; - string icon = 3; - string received_at = 4; -} - -message Stat { - int32 total_attempts = 1; - int32 solved_tasks = 2; -} - diff --git a/api/proto/competition.proto b/api/proto/competition.proto index fc32fa5..aebc8cc 100644 --- a/api/proto/competition.proto +++ b/api/proto/competition.proto @@ -1,34 +1,39 @@ syntax = "proto3"; package competition; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; + option go_package = "pkg/api/competition"; service CompetitionService { - rpc GetCompetition(GetCompetitionRequest) returns (GetCompetitionResponse); + rpc GetCompetition(GetCompetitionRequest) returns (Competition); rpc ListCompetitions(ListCompetitionsRequest) returns (ListCompetitionsResponse); - rpc ChangeCompetitionState(ChangeCompetitionStateRequest) returns (ChangeCompetitionStateResponse); + rpc CreateCompetition(CreateCompetitionRequest) returns (Competition); + rpc UpdateCompetition(UpdateCompetitionRequest) returns (Competition); + rpc DeleteCompetition(DeleteCompetitionRequest) returns (google.protobuf.Empty); + rpc ChangeCompetitionState(ChangeCompetitionStateRequest) returns (Competition); } -message GetCompetitionRequest { - string competition_id = 1; -} -message GetCompetitionResponse { - Competition competition = 1; +enum CompetitionState { + COMPETITION_STATE_UNSPECIFIED = 0; + COMPETITION_STATE_DRAFT = 1; + COMPETITION_STATE_NOT_STARTED = 2; + COMPETITION_STATE_STARTED = 3; + COMPETITION_STATE_FINISHED = 4; + COMPETITION_STATE_ARCHIVED = 5; } -message ListCompetitionsRequest { - bool is_participating = 1; -} -message ListCompetitionsResponse { - repeated Competition competitions = 1; +enum ParticipationType { + PARTICIPATION_TYPE_UNSPECIFIED = 0; + PARTICIPATION_TYPE_INDIVIDUAL = 1; + PARTICIPATION_TYPE_TEAM = 2; } -message ChangeCompetitionStateRequest { - string competition_id = 1; - CompetitionState state = 2; -} -message ChangeCompetitionStateResponse { - CompetitionState state = 1; +enum CompetitionType { + COMPETITION_TYPE_UNSPECIFIED = 0; + COMPETITION_TYPE_EDUCATIVE = 1; + COMPETITION_TYPE_COMPETETIVE = 2; } message Competition { @@ -37,16 +42,35 @@ message Competition { string title = 3; string description = 4; optional string image_url = 5; - optional string end_date = 6; - optional string start_date = 7; - string type = 8; - string participation_type = 9; + google.protobuf.Timestamp start_time = 6; + google.protobuf.Timestamp end_time = 7; + CompetitionType type = 8; + ParticipationType participation_type = 9; + google.protobuf.Timestamp created_at = 10; + google.protobuf.Timestamp updated_at = 11; } -enum CompetitionState { - COMPETITION_STATE_UNSPECIFIED = 0; - COMPETITION_STATE_NOT_STARTED = 1; - COMPETITION_STATE_STARTED = 2; - COMPETITION_STATE_FINISHED = 3; +message GetCompetitionRequest { + string competition_id = 1; } +message ListCompetitionsRequest { + int32 page_size = 1; + int32 page_token = 2; + + optional CompetitionState state = 3; + optional bool is_participating = 4; + optional string search_query = 5; +} + +message ListCompetitionsResponse { + int32 total_count = 2; + int32 next_page_token = 3; + + repeated Competition competitions = 1; +} + +message ChangeCompetitionStateRequest { + string competition_id = 1; + CompetitionState state = 2; +} diff --git a/api/proto/results.proto b/api/proto/results.proto new file mode 100644 index 0000000..6d82e57 --- /dev/null +++ b/api/proto/results.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; + +package results; + +import "google/protobuf/empty.proto"; + +option go_package = "pkg/api/results"; + +service ResultsService { + rpc GetCompetitionResults(GetCompetitionResultsRequest) returns (GetCompetitionResultsResponse); + rpc GetUserCompetitionResults(GetUserCompetitionResultsRequest) returns (GetUserCompetitionResultsResponse); + rpc RecalculateResults(RecalculateResultsRequest) returns (google.protobuf.Empty); +} + +message TaskStatus { + string task_id = 1; + string task_title = 2; + int32 earned_points = 3; + int32 max_points = 4; + optional int32 position = 5; +} + +message UserResult { + string user_id = 1; + string username = 2; + int32 total_score = 3; + int32 overall_position = 4; + repeated TaskStatus task_statuses = 5; +} + +message GetCompetitionResultsRequest { + int32 page_size = 1; + int32 page_token = 2; + + string competition_id = 3; +} + +message GetCompetitionResultsResponse { + repeated UserResult results = 1; + int32 total_count = 2; + int32 next_page_token = 3; +} + +message GetUserCompetitionResultsRequest { + string competition_id = 1; + string user_id = 2; +} +message GetUserCompetitionResultsResponse { + UserResult result = 1; +} + +message RecalculateResultsRequest { + string competition_id = 1; +} diff --git a/api/proto/review.proto b/api/proto/review.proto new file mode 100644 index 0000000..11b0998 --- /dev/null +++ b/api/proto/review.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; + +package review; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "pkg/api/review"; + +service ReviewService { + rpc ListSubmissionsForReview(ListSubmissionsForReviewRequest) returns (ListSubmissionsForReviewResponse); + rpc GetSubmissionForReview(GetSubmissionForReviewRequest) returns (SubmissionForReview); + rpc EvaluateSubmission(EvaluateSubmissionRequest) returns (EvaluateSubmissionResponse); + rpc ReleaseSubmission(ReleaseSubmissionRequest) returns (google.protobuf.Empty); +} + +enum ReviewStatus { + REVIEW_STATUS_UNSPECIFIED = 0; + REVIEW_STATUS_PENDING = 1; + REVIEW_STATUS_IN_REVIEW = 2; + REVIEW_STATUS_COMPLETED = 3; + REVIEW_STATUS_REJECTED = 4; +} + +message CriteriaMark { + string slug = 1; + double mark = 2; +} + +message SubmissionSummary { + string id = 1; + string competition_id = 2; + string task_id = 3; + string competition_title = 4; + string task_title = 5; + google.protobuf.Timestamp submitted_at = 6; + ReviewStatus review_status = 7; +} + +message SubmissionForReview { + string id = 1; + string competition_id = 2; + string task_id = 3; + string content = 4; + string description = 5; + ReviewStatus review_status = 6; + google.protobuf.Timestamp submitted_at = 7; + optional google.protobuf.Timestamp checked_at = 8; +} + +message ListSubmissionsForReviewRequest { + int32 page_size = 1; + int32 page_token = 2; + + optional ReviewStatus status = 3; +} +message ListSubmissionsForReviewResponse { + repeated SubmissionSummary submissions = 1; + int32 total_count = 2; + int32 next_page_token = 3; +} + +message GetSubmissionForReviewRequest { + string submission_id = 1; +} + +message EvaluateSubmissionRequest { + string submission_id = 1; + int32 earned_points = 2; + string reviewer_comment = 3; + repeated CriteriaMark marks = 4; +} +message EvaluateSubmissionResponse { + string submission_id = 1; + int32 final_score = 2; + ReviewStatus new_status = 3; +} + +message ReleaseSubmissionRequest { + string submission_id = 1; +} diff --git a/api/proto/submission.proto b/api/proto/submission.proto new file mode 100644 index 0000000..7af14f7 --- /dev/null +++ b/api/proto/submission.proto @@ -0,0 +1,68 @@ +syntax = "proto3"; +package submission; + +import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; + +option go_package = "pkg/api/submission"; + +service SubmissionService { + rpc SubmitTask(SubmitTaskRequest) returns (Submission); + rpc GetSubmissionsHistory(GetSubmissionsHistoryRequest) returns (GetSubmissionsHistoryResponse); + rpc GetSubmission(GetSubmissionRequest) returns (Submission); + rpc ListSubmissions(ListSubmissionsRequest) returns (ListSubmissionsResponse); +} + +enum SubmissionStatus { + SUBMISSION_STATUS_UNSPECIFIED = 0; + SUBMISSION_STATUS_PENDING = 1; + SUBMISSION_STATUS_SENT_FOR_CHECK = 2; + SUBMISSION_STATUS_CHECKING = 3; + SUBMISSION_STATUS_CHECKED = 4; + SUBMISSION_STATUS_FAILED = 5; +} + +message Submission { + string id = 1; + string user_id = 2; + string competition_id = 3; + string task_id = 4; + SubmissionStatus status = 5; + optional int32 earned_points = 6; + google.protobuf.Timestamp submitted_at = 7; + optional google.protobuf.Timestamp checked_at = 8; + string content = 9; +} + +message SubmitTaskRequest { + string competition_id = 1; + string task_id = 2; + bytes content = 3; +} + +message GetSubmissionsHistoryRequest { + string competition_id = 1; + string task_id = 2; +} +message GetSubmissionsHistoryResponse { + repeated Submission submissions = 1; +} + +message GetSubmissionRequest { + string submission_id = 1; +} + +message ListSubmissionsRequest { + int32 page_size = 1; + int32 page_token = 2; + + optional string competition_id = 3; + optional string task_id = 4; + optional string user_id = 5; + optional SubmissionStatus status = 6; +} +message ListSubmissionsResponse { + repeated Submission submissions = 1; + int32 total_count = 2; + int32 next_page_token = 3; +} diff --git a/api/proto/task.proto b/api/proto/task.proto index 8797531..78b4109 100644 --- a/api/proto/task.proto +++ b/api/proto/task.proto @@ -1,82 +1,15 @@ syntax = "proto3"; package task; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/empty.proto"; + option go_package = "pkg/api/task"; service TaskService { - rpc StartCompetition(StartCompetitionRequest) returns (StartCompetitionResponse); - rpc GetCompetitionTasks(GetCompetitionTasksRequest) returns (GetCompetitionTasksResponse); - rpc GetTask(GetTaskRequest) returns (GetTaskResponse); - rpc SubmitTask(SubmitTaskRequest) returns (SubmitTaskResponse); - rpc GetSubmissionsHistory(GetSubmissionsHistoryRequest) returns (GetSubmissionsHistoryResponse); + rpc GetTask(GetTaskRequest) returns (Task); + rpc ListCompetitionTasks(ListCompetitionTasksRequest) returns (ListCompetitionTasksResponse); rpc GetTaskAttachments(GetTaskAttachmentsRequest) returns (GetTaskAttachmentsResponse); - rpc GetCompetitionResults(GetCompetitionResultsRequest) returns (GetCompetitionResultsResponse); -} - -message StartCompetitionRequest { - string competition_id = 1; -} -message StartCompetitionResponse { - string status = 1; -} - -message GetCompetitionTasksRequest { - string competition_id = 1; -} -message GetCompetitionTasksResponse { - repeated Task tasks = 1; -} - -message GetTaskRequest { - string competition_id = 1; - string task_id = 2; -} -message GetTaskResponse { - Task task = 1; -} - -message SubmitTaskRequest { - string competition_id = 1; - string task_id = 2; - bytes content = 3; -} -message SubmitTaskResponse { - string submission_id = 1; -} - -message GetSubmissionsHistoryRequest { - string competition_id = 1; - string task_id = 2; -} -message GetSubmissionsHistoryResponse { - repeated HistorySubmission submissions = 1; -} - -message GetTaskAttachmentsRequest { - string competition_id = 1; - string task_id = 2; -} -message GetTaskAttachmentsResponse { - repeated TaskAttachment attachments = 1; -} - -message GetCompetitionResultsRequest { - string competition_id = 1; -} -message GetCompetitionResultsResponse { - repeated TaskStatus results = 1; -} - -message Task { - optional string id = 1; - string competition = 2; - string title = 3; - string description = 4; - int32 in_competition_position = 5; - optional int32 points = 6; - optional int32 max_attempts = 7; - TaskType type = 8; - TaskStatusEnum status = 9; } enum TaskType { @@ -86,32 +19,39 @@ enum TaskType { TASK_TYPE_REVIEW = 3; } -enum TaskStatusEnum { - TASK_STATUS_UNSPECIFIED = 0; - TASK_STATUS_NOT_SUBMITTED = 1; - TASK_STATUS_SENT = 2; - TASK_STATUS_CHECKING = 3; - TASK_STATUS_CHECKED = 4; -} - -message HistorySubmission { - optional string id = 1; - TaskStatusEnum status = 2; - optional int32 earned_points = 3; - string timestamp = 4; - string content = 5; +message Task { + string id = 1; + string competition_id = 2; + string title = 3; + string description = 4; + int32 in_competition_position = 5; + optional int32 max_points = 6; + optional int32 max_attempts = 7; + TaskType type = 8; + google.protobuf.Timestamp created_at = 9; + google.protobuf.Timestamp updated_at = 10; } message TaskAttachment { - optional string id = 1; - string file = 2; - bool public = 3; + string id = 1; + string file_url = 2; + bool is_public = 3; } -message TaskStatus { - string task_name = 1; - int32 result = 2; - int32 max_points = 3; - int32 position = 4; +message GetTaskRequest { + string task_id = 1; } +message ListCompetitionTasksRequest { + string competition_id = 1; +} +message ListCompetitionTasksResponse { + repeated Task tasks = 1; +} + +message GetTaskAttachmentsRequest { + string task_id = 1; +} +message GetTaskAttachmentsResponse { + repeated TaskAttachment attachments = 1; +} diff --git a/api/proto/user.proto b/api/proto/user.proto new file mode 100644 index 0000000..cb0e4b3 --- /dev/null +++ b/api/proto/user.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +package user; + +import "google/protobuf/empty.proto"; + +option go_package = "pkg/api/user"; + +service UserService { + rpc GetProfile(GetProfileRequest) returns (User); + rpc RegisterForCompetition(RegisterForCompetitionRequest) returns (google.protobuf.Empty); + rpc UnregisterFromCompetition(UnregisterFromCompetitionRequest) returns (google.protobuf.Empty); + rpc ListUserCompetitions(ListUserCompetitionsRequest) returns (ListUserCompetitionsResponse); +} + +message User { + string id = 1; + string username = 2; + string email = 3; + optional string full_name = 4; + optional string avatar_url = 5; +} + +message GetProfileRequest { + string user_id = 1; +} + +message RegisterForCompetitionRequest { + string competition_id = 1; +} +message UnregisterFromCompetitionRequest { + string competition_id = 1; +} + +message ListUserCompetitionsRequest { + string user_id = 1; +} +message ListUserCompetitionsResponse { + repeated string competition_ids = 1; +}