Skip to content

Commit

Permalink
Merge pull request #29 from Questspace-v2/wp/QUESTSPACE-9/0
Browse files Browse the repository at this point in the history
QUESTSPACE-9: Add endpoint to read answer logs
  • Loading branch information
BasedDepartment1 authored Oct 13, 2024
2 parents 17a5535 + 0f8ca45 commit d1a3d60
Show file tree
Hide file tree
Showing 14 changed files with 964 additions and 43 deletions.
1 change: 1 addition & 0 deletions src/cmd/questspace/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func InitApp(ctx context.Context, application *app.App) error {
r.H().Use(jwt.AuthMiddlewareStrict(jwtParser)).GET("/quest/:id/table", transport.WrapCtxErr(playHandler.HandleGetTableResults))
r.H().GET("/quest/:id/leaderboard", transport.WrapCtxErr(playHandler.HandleLeaderboard))
r.H().Use(jwt.AuthMiddlewareStrict(jwtParser)).POST("/quest/:id/penalty", transport.WrapCtxErr(playHandler.HandleAddPenalty))
r.H().Use(jwt.AuthMiddlewareStrict(jwtParser)).GET("/quest/:id/answer_log", transport.WrapCtxErr(playHandler.HandleAnswerLog))
return nil
}

Expand Down
170 changes: 162 additions & 8 deletions src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,93 @@ const docTemplate = `{
}
}
},
"/quest/{id}/answer_log": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"tags": [
"PlayMode"
],
"summary": "Get paginated answer logs",
"parameters": [
{
"type": "string",
"description": "Task group ID",
"name": "task_group",
"in": "query"
},
{
"type": "string",
"description": "Task ID",
"name": "task",
"in": "query"
},
{
"type": "string",
"description": "Team ID",
"name": "team",
"in": "query"
},
{
"type": "string",
"description": "User ID",
"name": "user",
"in": "query"
},
{
"type": "boolean",
"description": "Return only accepted answers",
"name": "accepted_only",
"in": "query"
},
{
"type": "boolean",
"description": "Return new answers first (descending)",
"name": "desc",
"in": "query"
},
{
"type": "integer",
"default": 50,
"description": "Number of answers to return for each field",
"name": "page_size",
"in": "query"
},
{
"type": "integer",
"description": "Page number to return. Mutually exclusive to page_id",
"name": "page_no",
"in": "query"
},
{
"type": "string",
"description": "Page ID to return. Mutually exclusive to page_no",
"name": "page_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/game.AnswerLogResponse"
}
},
"400": {
"description": "Bad Request"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not Found"
}
}
}
},
"/quest/{id}/hint": {
"post": {
"security": [
Expand Down Expand Up @@ -1356,6 +1443,61 @@ const docTemplate = `{
}
}
},
"game.AnswerLog": {
"type": "object",
"properties": {
"accepted": {
"type": "boolean"
},
"answer": {
"type": "string"
},
"answer_time": {
"type": "string"
},
"task": {
"type": "string"
},
"task_group": {
"type": "string"
},
"task_group_id": {
"type": "string"
},
"task_id": {
"type": "string"
},
"team": {
"type": "string"
},
"team_id": {
"type": "string"
},
"user": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"game.AnswerLogResponse": {
"type": "object",
"properties": {
"answer_logs": {
"type": "array",
"items": {
"$ref": "#/definitions/game.AnswerLog"
}
},
"next_page_token": {
"type": "integer"
},
"total_pages": {
"type": "integer"
}
}
},
"game.AnswerTask": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1898,17 +2040,29 @@ const docTemplate = `{
"example": "2024-04-14T14:00:00+05:00"
},
"status": {
"type": "string",
"enum": [
"ON_REGISTRATION",
"REGISTRATION_DONE",
"RUNNING",
"WAIT_RESULTS",
"FINISHED"
]
"$ref": "#/definitions/storage.QuestStatus"
}
}
},
"storage.QuestStatus": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4,
5
],
"x-enum-varnames": [
"StatusUnspecified",
"StatusOnRegistration",
"StatusRegistrationDone",
"StatusRunning",
"StatusWaitResults",
"StatusFinished"
]
},
"storage.Task": {
"type": "object",
"properties": {
Expand Down
170 changes: 162 additions & 8 deletions src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,93 @@
}
}
},
"/quest/{id}/answer_log": {
"get": {
"security": [
{
"ApiKeyAuth": []
}
],
"tags": [
"PlayMode"
],
"summary": "Get paginated answer logs",
"parameters": [
{
"type": "string",
"description": "Task group ID",
"name": "task_group",
"in": "query"
},
{
"type": "string",
"description": "Task ID",
"name": "task",
"in": "query"
},
{
"type": "string",
"description": "Team ID",
"name": "team",
"in": "query"
},
{
"type": "string",
"description": "User ID",
"name": "user",
"in": "query"
},
{
"type": "boolean",
"description": "Return only accepted answers",
"name": "accepted_only",
"in": "query"
},
{
"type": "boolean",
"description": "Return new answers first (descending)",
"name": "desc",
"in": "query"
},
{
"type": "integer",
"default": 50,
"description": "Number of answers to return for each field",
"name": "page_size",
"in": "query"
},
{
"type": "integer",
"description": "Page number to return. Mutually exclusive to page_id",
"name": "page_no",
"in": "query"
},
{
"type": "string",
"description": "Page ID to return. Mutually exclusive to page_no",
"name": "page_id",
"in": "query"
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/game.AnswerLogResponse"
}
},
"400": {
"description": "Bad Request"
},
"403": {
"description": "Forbidden"
},
"404": {
"description": "Not Found"
}
}
}
},
"/quest/{id}/hint": {
"post": {
"security": [
Expand Down Expand Up @@ -1345,6 +1432,61 @@
}
}
},
"game.AnswerLog": {
"type": "object",
"properties": {
"accepted": {
"type": "boolean"
},
"answer": {
"type": "string"
},
"answer_time": {
"type": "string"
},
"task": {
"type": "string"
},
"task_group": {
"type": "string"
},
"task_group_id": {
"type": "string"
},
"task_id": {
"type": "string"
},
"team": {
"type": "string"
},
"team_id": {
"type": "string"
},
"user": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"game.AnswerLogResponse": {
"type": "object",
"properties": {
"answer_logs": {
"type": "array",
"items": {
"$ref": "#/definitions/game.AnswerLog"
}
},
"next_page_token": {
"type": "integer"
},
"total_pages": {
"type": "integer"
}
}
},
"game.AnswerTask": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1887,17 +2029,29 @@
"example": "2024-04-14T14:00:00+05:00"
},
"status": {
"type": "string",
"enum": [
"ON_REGISTRATION",
"REGISTRATION_DONE",
"RUNNING",
"WAIT_RESULTS",
"FINISHED"
]
"$ref": "#/definitions/storage.QuestStatus"
}
}
},
"storage.QuestStatus": {
"type": "integer",
"enum": [
0,
1,
2,
3,
4,
5
],
"x-enum-varnames": [
"StatusUnspecified",
"StatusOnRegistration",
"StatusRegistrationDone",
"StatusRunning",
"StatusWaitResults",
"StatusFinished"
]
},
"storage.Task": {
"type": "object",
"properties": {
Expand Down
Loading

0 comments on commit d1a3d60

Please sign in to comment.