-
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.
- Loading branch information
Showing
39 changed files
with
967 additions
and
221 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,53 @@ | ||
allOf: | ||
- $ref: "#/components/schemas/DailyQuestionKey" | ||
- type: object | ||
x-go-is-request: true | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
required: | ||
- ID | ||
- title | ||
- time_for_answer | ||
- reward | ||
- answer_options | ||
- active | ||
- starts_at | ||
- created_at | ||
properties: | ||
ID: | ||
type: integer | ||
format: int | ||
description: ID question | ||
example: 88 | ||
title: | ||
type: string | ||
description: Title question | ||
example: Georgian capital | ||
time_for_answer: | ||
type: integer | ||
format: int | ||
description: Time for answer | ||
example: 86400 | ||
reward: | ||
type: integer | ||
format: int | ||
description: Reward for the right answer | ||
example: 77 | ||
answer_options: | ||
$ref: '#/components/schemas/DailyQuestionAnswers' | ||
description: answer options | ||
Active: | ||
type: boolean | ||
description: Status activity event | ||
example: true | ||
starts_at: | ||
type: time.Time | ||
format: int | ||
description: Event start date, after which the event becomes active | ||
created_at: | ||
type: time.Time | ||
format: int | ||
description: Event add date |
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,25 @@ | ||
allOf: | ||
- $ref: '#/components/schemas/DailyQuestionKey' | ||
- type: object | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
required: | ||
- question_id | ||
- nullifier | ||
- answer | ||
properties: | ||
question_id: | ||
type: integer | ||
format: int | ||
description: ID in table daily_question | ||
nullifier: | ||
type: string | ||
description: Nullifier of the user who gave the answer | ||
example: "0x123...abc" | ||
pattern: '^0x[0-9a-fA-F]{64}$' | ||
answer: | ||
type: string | ||
example: "That day is May 26, 2025" |
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,5 @@ | ||
type: object | ||
properties: | ||
type: string | ||
format: json.RawMessage | ||
description: Some events require dynamic data, which can be filled into `static` template. |
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 | ||
properties: | ||
id: | ||
type: integer | ||
format: int64 | ||
description: id question | ||
example: 12 | ||
type: | ||
type: string | ||
enum: [daily_question ] |
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,21 @@ | ||
allOf: | ||
- $ref: '#/components/schemas/DailyQuestionKey' | ||
- type: object | ||
x-go-is-request: true | ||
required: | ||
- attributes | ||
properties: | ||
attributes: | ||
type: object | ||
required: | ||
- time_to_next | ||
- answer_status | ||
properties: | ||
time_to_next: | ||
type: integer | ||
format: int64 | ||
description: time to next question of the day | ||
example: 312334324 | ||
answer_status: | ||
type: boolean | ||
description: Right or wrong answers |
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,55 @@ | ||
get: | ||
description: daily question | ||
parameters: | ||
- $ref: '#/components/parameters/DailyQuestion' | ||
name: Signature | ||
description: Signature of the request | ||
response: | ||
200: | ||
description: Success | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestion' | ||
400: | ||
$ref: '#/components/responses/invalidParameter' | ||
401: | ||
$ref: '#/components/responses/invalidAuth' | ||
500: | ||
$ref: '#/components/responses/internalError' | ||
|
||
patch: | ||
description: Send daily question answer | ||
requestBody: | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestionAnswer' | ||
response: | ||
200: | ||
description: Success | ||
content: | ||
application/vnd.api+json: | ||
schema: | ||
type: object | ||
required: | ||
- data | ||
properties: | ||
data: | ||
$ref: '#/components/schemas/DailyQuestion' | ||
400: | ||
$ref: '#/components/responses/invalidParameter' | ||
401: | ||
$ref: '#/components/responses/invalidAuth' | ||
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
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,16 @@ | ||
package config | ||
|
||
import "time" | ||
|
||
type TimeZoneProvider interface { | ||
UtcTimeZone() *time.Location | ||
} | ||
|
||
func (c *config) UtcTimeZone() *time.Location { | ||
return c.timeZone | ||
} | ||
|
||
func NowTime() time.Time { | ||
loc, _ := time.LoadLocation(locationName) | ||
return time.Now().In(loc) | ||
} |
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 |
---|---|---|
@@ -1,23 +1,29 @@ | ||
package data | ||
|
||
type DailyQuestions struct { | ||
ID int `db:"id"` | ||
Title string `db:"title"` | ||
TimeForAnswer int `db:"time_for_answer"` | ||
Bounty int `db:"bounty"` | ||
AnswerOptions string `db:"answer_options"` | ||
Active bool `db:"active"` | ||
StartsAt int `db:"starts_at"` | ||
import "time" | ||
|
||
type DailyQuestion struct { | ||
ID int `db:"id"` | ||
Title string `db:"title"` | ||
TimeForAnswer int `db:"time_for_answer"` | ||
Reward int `db:"reward"` | ||
AnswerOptions Jsonb `db:"answer_options"` | ||
Active bool `db:"active"` | ||
StartsAt time.Time `db:"starts_at"` | ||
CreatedAt time.Time `db:"created_at"` | ||
} | ||
|
||
type DailyQuestionsQ interface { | ||
New() DailyQuestionsQ | ||
Insert(DailyQuestions) error | ||
type DailyQuestionQ interface { | ||
New() DailyQuestionQ | ||
Insert(DailyQuestion) error | ||
Update(map[string]any) error | ||
|
||
Count() (int64, error) | ||
Select() ([]DailyQuestions, error) | ||
Select() ([]DailyQuestion, error) | ||
Get() (*DailyQuestion, error) | ||
|
||
FilteredActive(status bool) DailyQuestionsQ | ||
FilteredStartAt(date int) DailyQuestionsQ | ||
FilterByActive(status bool) DailyQuestionQ | ||
FilterByStartAt(date time.Time) DailyQuestionQ | ||
FilterByCreatedAt(date time.Time) DailyQuestionQ | ||
FilterByID(ID int) DailyQuestionQ | ||
} |
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.