diff --git a/cmd/web/handlers.go b/cmd/web/handlers.go index bbd7ec4..299def8 100644 --- a/cmd/web/handlers.go +++ b/cmd/web/handlers.go @@ -87,7 +87,7 @@ func (app *application) CreateElection(w http.ResponseWriter, r *http.Request) { var res []byte if request.AreVotersKnown { - voterIdentities := make([]string, 0, request.MaxVoters) + voterIdentities := make([]string, 0, request.MaxVoters) // TODO: this is way too slow for i := 0; i < request.MaxVoters; i++ { randomIdentity := randomVoterIdentity() _, err := app.voters.Insert(randomIdentity, electionId) diff --git a/cmd/web/main.go b/cmd/web/main.go index 4ef94cf..48dc8bc 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -48,7 +48,7 @@ func main() { Addr: addr, Handler: app.routes(), ErrorLog: slog.NewLogLogger(logger.Handler(), slog.LevelError), - IdleTimeout: time.Minute, + IdleTimeout: 6 * time.Minute, ReadTimeout: 5 * time.Second, WriteTimeout: 10 * time.Second, } diff --git a/cmd/web/openapi.yml b/cmd/web/openapi.yml index 2634f71..c3b2c8f 100644 --- a/cmd/web/openapi.yml +++ b/cmd/web/openapi.yml @@ -133,107 +133,6 @@ paths: components: schemas: - Election: - type: object - required: - - id - - name - - tokens - - areVotersKnown - - maxVoters - - expiresAt - properties: - id: - type: integer - format: int64 - readOnly: true - name: - type: string - minLength: 1 - tokens: - type: integer - minimum: 1 - areVotersKnown: - type: boolean - maxVoters: - type: integer - minimum: 0 - description: Must be greater than 0 when voters are known - createdAt: - type: string - format: date-time - readOnly: true - expiresAt: - type: string - format: date-time - choices: - type: array - items: - $ref: '#/components/schemas/Choice' - voters: - type: array - items: - $ref: '#/components/schemas/Voter' - - Choice: - type: object - required: - - text - - electionId - properties: - text: - type: string - minLength: 1 - electionId: - type: integer - format: int64 - - Voter: - type: object - required: - - identity - - electionId - properties: - identity: - type: string - minLength: 1 - description: When voters are known, passcodes will be pre-generated - electionId: - type: integer - format: int64 - votes: - type: array - items: - $ref: '#/components/schemas/Vote' - - Vote: - type: object - required: - - voterIdentity - - electionId - properties: - voterIdentity: - type: string - minLength: 1 - electionId: - type: integer - format: int64 - choiceText: - type: string - nullable: true - tokens: - type: integer - minimum: 1 - nullable: true - calculatedVoteCount: - type: integer - readOnly: true - description: Calculated as floor(sqrt(tokens)) - createdAt: - type: string - format: date-time - readOnly: true - CreateElectionRequest: type: object required: diff --git a/ui/create-election.html b/ui/create-election.html index 3884f6d..2b7bcda 100644 --- a/ui/create-election.html +++ b/ui/create-election.html @@ -4,63 +4,152 @@