Environment variable option for minimum teacher vote selection count #95
|
@ -22,6 +22,7 @@ POSTGRES_USER="mw"
|
|||
POSTGRES_PASSWORD=
|
||||
|
||||
# Backend
|
||||
BACKEND_MIN_TEACHER_SELECTION_COUNT=
|
||||
BACKEND_URL=URL
|
||||
# Backend - API
|
||||
BACKEND_API_GRAPHQL_PLAYGROUND=false
|
||||
|
|
|
@ -77,6 +77,7 @@ services:
|
|||
- redis
|
||||
environment:
|
||||
BACKEND_URL: ${URL}
|
||||
BACKEND_MIN_TEACHER_SELECTION_COUNT: ${BACKEND_MIN_TEACHER_SELECTION_COUNT}
|
||||
BACKEND_API_GRAPHQL_PLAYGROUND: ${BACKEND_API_GRAPHQL_PLAYGROUND}
|
||||
BACKEND_API_JWT_SECRET: ${BACKEND_API_JWT_SECRET}
|
||||
BACKEND_API_JWT_EXPIRATION: ${BACKEND_API_JWT_EXPIRATION}
|
||||
|
|
|
@ -143,7 +143,7 @@ module Backend
|
|||
def create_vote(context : Context, input : VoteCreateInput) : Vote
|
||||
context.student!
|
||||
|
||||
raise "Not enough teachers" if input.teacher_ids.empty?
|
||||
raise "Not enough teachers" if input.teacher_ids.size < Backend.config.min_teacher_selection_count
|
||||
teacher_role_count = Db::User.where(role: Db::UserRole::Teacher.to_s).count.run.as(Int64)
|
||||
raise "Teachers not registered" if teacher_role_count != Db::Teacher.count ||
|
||||
teacher_role_count.zero?
|
||||
|
|
|
@ -58,6 +58,9 @@ module Backend
|
|||
# Base URL of application
|
||||
getter url : String
|
||||
|
||||
# Minimum teacher selection count
|
||||
getter min_teacher_selection_count : Int32
|
||||
|
||||
@[EnvConfig::Setting(key: "api")]
|
||||
# Configuration for `Api`
|
||||
getter api : ApiConfig
|
||||
|
|
Loading…
Reference in a new issue