Skip to content

Commit

Permalink
added api to check the status of the quiz kyc
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-ares committed Feb 1, 2024
1 parent 498a8d7 commit 28fc0b5
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
4 changes: 4 additions & 0 deletions application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ kyc/quiz:
maxQuestionsPerSession: 3
maxWrongAnswersPerSession: 1
sessionCoolDownSeconds: 3600
maxResetCount: 0
maxAttemptsAllowed: 3
availabilityWindowSeconds: 600
globalStartDate: 2024-01-01
auth/email-link:
wintr/connectors/storage/v2: *db
fromEmailAddress: [email protected]
Expand Down
9 changes: 9 additions & 0 deletions cmd/eskimo-hut/api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,9 @@ const docTemplate = `{
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
"kycQuizAvailable": {
"type": "boolean"
},
"kycQuizCompleted": {
"type": "boolean"
},
Expand Down Expand Up @@ -2039,6 +2042,9 @@ const docTemplate = `{
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
"kycQuizAvailable": {
"type": "boolean"
},
"kycQuizCompleted": {
"type": "boolean"
},
Expand Down Expand Up @@ -2202,6 +2208,9 @@ const docTemplate = `{
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
"kycQuizAvailable": {
"type": "boolean"
},
"kycQuizCompleted": {
"type": "boolean"
},
Expand Down
9 changes: 9 additions & 0 deletions cmd/eskimo-hut/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1702,6 +1702,9 @@
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
"kycQuizAvailable": {
"type": "boolean"
},
"kycQuizCompleted": {
"type": "boolean"
},
Expand Down Expand Up @@ -2033,6 +2036,9 @@
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
"kycQuizAvailable": {
"type": "boolean"
},
"kycQuizCompleted": {
"type": "boolean"
},
Expand Down Expand Up @@ -2196,6 +2202,9 @@
"kycQuizAvailabilityEndedAt": {
"type": "string"
},
"kycQuizAvailable": {
"type": "boolean"
},
"kycQuizCompleted": {
"type": "boolean"
},
Expand Down
6 changes: 6 additions & 0 deletions cmd/eskimo-hut/api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ definitions:
type: string
kycQuizAvailabilityEndedAt:
type: string
kycQuizAvailable:
type: boolean
kycQuizCompleted:
type: boolean
kycQuizDisabled:
Expand Down Expand Up @@ -332,6 +334,8 @@ definitions:
type: string
kycQuizAvailabilityEndedAt:
type: string
kycQuizAvailable:
type: boolean
kycQuizCompleted:
type: boolean
kycQuizDisabled:
Expand Down Expand Up @@ -443,6 +447,8 @@ definitions:
properties:
kycQuizAvailabilityEndedAt:
type: string
kycQuizAvailable:
type: boolean
kycQuizCompleted:
type: boolean
kycQuizDisabled:
Expand Down
1 change: 1 addition & 0 deletions kyc/quiz/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ type (
KYCQuizAvailabilityEndedAt *time.Time `json:"kycQuizAvailabilityEndedAt" db:"kyc_quiz_availability_ended_at"`
KYCQuizResetAt []*time.Time `json:"kycQuizResetAt,omitempty" db:"kyc_quiz_reset_at"`
KYCQuizRemainingAttempts uint8 `json:"kycQuizRemainingAttempts,omitempty" db:"kyc_quiz_remaining_attempts"`
KYCQuizAvailable bool `json:"kycQuizAvailable" db:"kyc_quiz_available"`
KYCQuizDisabled bool `json:"kycQuizDisabled" db:"kyc_quiz_disabled"`
KYCQuizCompleted bool `json:"kycQuizCompleted" db:"kyc_quiz_completed"`
HasUnfinishedSessions bool `json:"-"`
Expand Down
1 change: 1 addition & 0 deletions kyc/quiz/quiz.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ func (r *repositoryImpl) getQuizStatus(ctx context.Context, userID UserID) (*Qui
qr.resets AS kyc_quiz_reset_at,
(qs.user_id IS NOT NULL AND qs.ended_at is not null AND qs.ended_successfully = true) AS kyc_quiz_completed,
GREATEST(u.created_at,$2) + (interval '1 second' * $3) AS kyc_quiz_availability_ended_at,
(u.kyc_step_passed >= 2 AND u.kyc_step_blocked = 0) AS kyc_quiz_available,
(qs.user_id IS NOT NULL AND qs.ended_at IS NULL) AS has_unfinished_sessions
FROM users u
LEFT JOIN quiz_resets qr
Expand Down

0 comments on commit 28fc0b5

Please sign in to comment.