-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from rarimo/feat/daily_questions_rework
Feat/daily questions rework
- Loading branch information
Showing
36 changed files
with
1,283 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
allOf: | ||
- $ref: '#/components/schemas/DailyQuestionsKey' | ||
- type: object | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
required: | ||
- answer | ||
properties: | ||
answer: | ||
type: integer | ||
format: int64 | ||
description: Selected/correct answer option |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
type: object | ||
required: | ||
- id | ||
- title | ||
properties: | ||
id: | ||
type: integer | ||
format: int | ||
description: Answer number for the question | ||
title: | ||
type: string | ||
description: Answer text |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
allOf: | ||
- $ref: "#/components/schemas/DailyQuestionsKey" | ||
- type: object | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
required: | ||
- title | ||
- options | ||
properties: | ||
title: | ||
type: string | ||
description: Question title | ||
example: Georgian capital | ||
options: | ||
type: array | ||
description: Answer options. Minimum 2, maximum 6 | ||
items: | ||
$ref: "#/components/schemas/DailyQuestionOptions" | ||
example: [ | ||
{ | ||
"id": 0, | ||
"title": "" | ||
}, | ||
{ | ||
"id": 1, | ||
"title": "" | ||
}, | ||
{ | ||
"id": 2, | ||
"title": "" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type: object | ||
required: | ||
- id | ||
- type | ||
properties: | ||
id: | ||
type: string | ||
description: Question id | ||
type: | ||
type: string | ||
enum: [ daily_questions ] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
allOf: | ||
- $ref: "#/components/schemas/DailyQuestionsStatusKey" | ||
- type: object | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
required: | ||
- next_question_date | ||
- time_for_answer | ||
- reward | ||
properties: | ||
next_question_date: | ||
type: timestamp | ||
format: int64 | ||
description: | | ||
Time when the next question will be available. | ||
If the time is in the past, then there is a question | ||
on this day and the user has not yet answered it. | ||
If the time is in the future, then the user has either | ||
already answered the question on the current day or | ||
there was no question on the current day. | ||
example: 1725018539 | ||
time_for_answer: | ||
type: integer | ||
format: int64 | ||
description: The time within which the user has to answer this question after receiving it. | ||
example: 30 | ||
reward: | ||
type: integer | ||
format: int64 | ||
description: The number of points the user will receive if they answer the question correctly. | ||
example: 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
type: object | ||
required: | ||
- id | ||
- type | ||
properties: | ||
id: | ||
type: string | ||
description: Question id | ||
type: | ||
type: string | ||
enum: [ daily_questions_status ] |
93 changes: 93 additions & 0 deletions
93
docs/spec/paths/integrations@geo-points-svc@v1@public@daily_questions@{nullifier}.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
get: | ||
tags: | ||
- Daily Questions | ||
summary: Get daily question | ||
description: | | ||
Get a daily question. The user must be | ||
authorized and verified (passport scanned, | ||
verified field is true). | ||
operationId: getDailyQuestion | ||
security: | ||
- BearerAuth: [] | ||
responses: | ||
200: | ||
description: Success | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestions' | ||
400: | ||
$ref: '#/components/responses/invalidParameter' | ||
401: | ||
$ref: '#/components/responses/invalidAuth' | ||
403: | ||
description: Questions unavailable, try later | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
$ref: '#/components/schemas/Errors' | ||
404: | ||
description: There is no question in current day. | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
$ref: '#/components/schemas/Errors' | ||
409: | ||
description: User already answer current day question. | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
$ref: '#/components/schemas/Errors' | ||
500: | ||
$ref: '#/components/responses/internalError' | ||
|
||
post: | ||
tags: | ||
- Daily Questions | ||
summary: Answer question | ||
description: | | ||
Answer question. The user must be | ||
authorized and verified (passport scanned, | ||
verified field is true). | ||
operationId: answerDailyQuestion | ||
security: | ||
- BearerAuth: [] | ||
requestBody: | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestionAnswers' | ||
responses: | ||
200: | ||
description: Success | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestionAnswers' | ||
400: | ||
$ref: '#/components/responses/invalidParameter' | ||
401: | ||
$ref: '#/components/responses/invalidAuth' | ||
404: | ||
description: User haven't active question or deadline already passed. | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
$ref: '#/components/schemas/Errors' | ||
500: | ||
$ref: '#/components/responses/internalError' |
34 changes: 34 additions & 0 deletions
34
.../spec/paths/integrations@geo-points-svc@v1@public@daily_questions@{nullifier}@status.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
get: | ||
tags: | ||
- Daily Questions | ||
summary: Daily question status | ||
description: | | ||
Get the status of questions. The user must be | ||
authorized and verified (passport scanned, | ||
verified field is true). | ||
Returns NotFound if next question absent. | ||
operationId: dailyQuestionsStatus | ||
security: | ||
- BearerAuth: [] | ||
responses: | ||
200: | ||
description: Success | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestionsStatus' | ||
401: | ||
$ref: '#/components/responses/invalidAuth' | ||
404: | ||
description: Next question not exist. | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
$ref: '#/components/schemas/Errors' | ||
500: | ||
$ref: '#/components/responses/internalError' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-- +migrate Up | ||
CREATE TABLE IF NOT EXISTS daily_questions ( | ||
id SERIAL PRIMARY KEY, | ||
title VARCHAR(255) NOT NULL, | ||
time_for_answer INTEGER NOT NULL, | ||
reward INTEGER NOT NULL, | ||
answer_options JSONB NOT NULL, | ||
starts_at TIMESTAMP NOT NULL, | ||
created_at TIMESTAMP NOT NULL DEFAULT (NOW() AT TIME ZONE 'utc'), | ||
correct_answer INTEGER NOT NULL, | ||
num_correct_answers INTEGER DEFAULT 0, | ||
num_incorrect_answers INTEGER DEFAULT 0, | ||
num_all_participants INTEGER DEFAULT 0 | ||
); | ||
|
||
-- +migrate Down | ||
DROP TABLE IF EXISTS daily_questions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.