Skip to content

Commit

Permalink
Feature quiz reset (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
ice-dionysos authored Feb 1, 2024
1 parent d1dd3be commit 498a8d7
Show file tree
Hide file tree
Showing 6 changed files with 445 additions and 58 deletions.
1 change: 1 addition & 0 deletions cmd/eskimo-hut/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ const (
noPendingLoginSessionErrorCode = "NO_PENDING_LOGIN_SESSION"

quizUnknownQuestionNumErrorCode = "QUIZ_UNKNOWN_QUESTION_NUM"
quizDisbledErrorCode = "QUIZ_DISABLED"

socialKYCStepAlreadyCompletedSuccessfullyErrorCode = "SOCIAL_KYC_STEP_ALREADY_COMPLETED_SUCCESSFULLY"
socialKYCStepNotAvailableErrorCode = "SOCIAL_KYC_STEP_NOT_AVAILABLE"
Expand Down
3 changes: 3 additions & 0 deletions cmd/eskimo-hut/kyc.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ func (s *service) StartOrContinueKYCStep4Session( //nolint:gocritic,funlen // .
case errors.Is(err, kycquiz.ErrSessionFinished), errors.Is(err, kycquiz.ErrSessionFinishedWithError), errors.Is(err, kycquiz.ErrInvalidKYCState): //nolint:lll // .
return nil, server.BadRequest(err, raceConditionErrorCode)

case errors.Is(err, kycquiz.ErrNotAvailable):
return nil, server.ForbiddenWithCode(err, quizDisbledErrorCode)

default:
return nil, server.Unexpected(err)
}
Expand Down
6 changes: 5 additions & 1 deletion kyc/quiz/.testdata/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ kyc/quiz:
maxSessionDurationSeconds: 600
maxQuestionsPerSession: 3
maxWrongAnswersPerSession: 1
sessionCoolDownSeconds: 3600
sessionCoolDownSeconds: 3600
maxResetCount: 2
maxAttemptsAllowed: 3
availabilityWindowSeconds: 604800
globalStartDate: 2024-01-01
19 changes: 12 additions & 7 deletions kyc/quiz/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ var (
ErrSessionFinishedWithError = newError("session closed with error")
ErrUnknownQuestionNumber = newError("unknown question number")
ErrUnknownSession = newError("unknown session and/or user")
ErrNotAvailable = newError("quiz kyc not available")
)

const (
Expand Down Expand Up @@ -118,12 +119,16 @@ type (
}
config struct {
alertFrequency *atomic.Pointer[stdlibtime.Duration]
Environment string `yaml:"environment" mapstructure:"environment"`
AlertSlackWebhook string `yaml:"alert-slack-webhook" mapstructure:"alert-slack-webhook"` //nolint:tagliatelle // .
MaxSessionDurationSeconds int `yaml:"maxSessionDurationSeconds"`
MaxQuestionsPerSession int `yaml:"maxQuestionsPerSession"`
MaxWrongAnswersPerSession int `yaml:"maxWrongAnswersPerSession"`
SessionCoolDownSeconds int `yaml:"sessionCoolDownSeconds"`
EnableAlerts bool `yaml:"enable-alerts" mapstructure:"enable-alerts"` //nolint:tagliatelle // .
MaxResetCount *uint8 `yaml:"maxResetCount"`
GlobalStartDate *time.Time `yaml:"globalStartDate" example:"YYYY-MM-DD"`
Environment string `yaml:"environment" mapstructure:"environment"`
AlertSlackWebhook string `yaml:"alert-slack-webhook" mapstructure:"alert-slack-webhook"` //nolint:tagliatelle // .
AvailabilityWindowSeconds int `yaml:"availabilityWindowSeconds"`
MaxSessionDurationSeconds int `yaml:"maxSessionDurationSeconds"`
MaxQuestionsPerSession int `yaml:"maxQuestionsPerSession"`
MaxWrongAnswersPerSession int `yaml:"maxWrongAnswersPerSession"`
SessionCoolDownSeconds int `yaml:"sessionCoolDownSeconds"`
EnableAlerts bool `yaml:"enable-alerts" mapstructure:"enable-alerts"` //nolint:tagliatelle // .
MaxAttemptsAllowed uint8 `yaml:"maxAttemptsAllowed"`
}
)
Loading

0 comments on commit 498a8d7

Please sign in to comment.