Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions apps/uno/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,61 @@ const docTemplate = `{
}
}
},
"/happenings/{id}/registrations/{userId}/attendance/{attended}": {
"put": {
"description": "Sets whether a specific user attended a happening.",
"produces": [
"application/json"
],
"tags": [
"happenings"
],
"summary": "Set user attendance",
"parameters": [
{
"type": "string",
"description": "Happening ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User ID",
"name": "userId",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "Attendance status",
"name": "attended",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/happenings/{id}/spot-ranges": {
"get": {
"description": "Retrieves all spot ranges for a specific happening.",
Expand Down Expand Up @@ -5764,6 +5819,9 @@ const docTemplate = `{
"$ref": "#/definitions/uno_http_dto.RegistrationAnswerWithQuestionResponse"
}
},
"attended": {
"type": "boolean"
},
"changedAt": {
"type": "string"
},
Expand Down Expand Up @@ -5827,6 +5885,9 @@ const docTemplate = `{
"uno_http_dto.HappeningRegistrationResponse": {
"type": "object",
"properties": {
"attended": {
"type": "boolean"
},
"changedAt": {
"type": "string"
},
Expand Down Expand Up @@ -6136,6 +6197,9 @@ const docTemplate = `{
"uno_http_dto.RegistrationResponse": {
"type": "object",
"properties": {
"attended": {
"type": "boolean"
},
"changedAt": {
"type": "string"
},
Expand Down
64 changes: 64 additions & 0 deletions apps/uno/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,61 @@
}
}
},
"/happenings/{id}/registrations/{userId}/attendance/{attended}": {
"put": {
"description": "Sets whether a specific user attended a happening.",
"produces": [
"application/json"
],
"tags": [
"happenings"
],
"summary": "Set user attendance",
"parameters": [
{
"type": "string",
"description": "Happening ID",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User ID",
"name": "userId",
"in": "path",
"required": true
},
{
"type": "boolean",
"description": "Attendance status",
"name": "attended",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "string"
}
},
"400": {
"description": "Bad Request",
"schema": {
"type": "string"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"type": "string"
}
}
}
}
},
"/happenings/{id}/spot-ranges": {
"get": {
"description": "Retrieves all spot ranges for a specific happening.",
Expand Down Expand Up @@ -5757,6 +5812,9 @@
"$ref": "#/definitions/uno_http_dto.RegistrationAnswerWithQuestionResponse"
}
},
"attended": {
"type": "boolean"
},
"changedAt": {
"type": "string"
},
Expand Down Expand Up @@ -5820,6 +5878,9 @@
"uno_http_dto.HappeningRegistrationResponse": {
"type": "object",
"properties": {
"attended": {
"type": "boolean"
},
"changedAt": {
"type": "string"
},
Expand Down Expand Up @@ -6129,6 +6190,9 @@
"uno_http_dto.RegistrationResponse": {
"type": "object",
"properties": {
"attended": {
"type": "boolean"
},
"changedAt": {
"type": "string"
},
Expand Down
43 changes: 43 additions & 0 deletions apps/uno/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,8 @@ definitions:
items:
$ref: '#/definitions/uno_http_dto.RegistrationAnswerWithQuestionResponse'
type: array
attended:
type: boolean
changedAt:
type: string
changedBy:
Expand Down Expand Up @@ -916,6 +918,8 @@ definitions:
type: object
uno_http_dto.HappeningRegistrationResponse:
properties:
attended:
type: boolean
changedAt:
type: string
changedBy:
Expand Down Expand Up @@ -1117,6 +1121,8 @@ definitions:
type: object
uno_http_dto.RegistrationResponse:
properties:
attended:
type: boolean
changedAt:
type: string
changedBy:
Expand Down Expand Up @@ -2661,6 +2667,43 @@ paths:
summary: Update registration status
tags:
- happenings
/happenings/{id}/registrations/{userId}/attendance/{attended}:
put:
description: Sets whether a specific user attended a happening.
parameters:
- description: Happening ID
in: path
name: id
required: true
type: string
- description: User ID
in: path
name: userId
required: true
type: string
- description: Attendance status
in: path
name: attended
required: true
type: boolean
produces:
- application/json
responses:
"200":
description: OK
schema:
type: string
"400":
description: Bad Request
schema:
type: string
"500":
description: Internal Server Error
schema:
type: string
summary: Set user attendance
tags:
- happenings
/happenings/{id}/registrations/full:
get:
description: Retrieves full registration rows for a specific happening, enriched
Expand Down
1 change: 1 addition & 0 deletions apps/uno/domain/model/happening.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ type HappeningRegistration struct {
UserYear *int
UserDegreeID *string
UserHasImage bool
Attended *bool
}

type FullHappeningRegistration struct {
Expand Down
1 change: 1 addition & 0 deletions apps/uno/domain/model/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type Registration struct {
PrevStatus *string
ChangedAt *time.Time
ChangedBy *string
Attended *bool
}

// IsActive checks if the registration is in an active state
Expand Down
69 changes: 69 additions & 0 deletions apps/uno/domain/port/mocks/RegistrationRepo.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions apps/uno/domain/port/registration.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ type RegistrationRepo interface {
DeleteAnswersByUserAndHappening(ctx context.Context, userID, happeningID string) error
UpdateRegistrationStatus(ctx context.Context, userID, happeningID string, status model.RegistrationStatus, prevStatus *string, changedBy *string, changedAt *time.Time, unregisterReason *string) error
DeleteRegistrationsByHappeningID(ctx context.Context, happeningID string) error
SetAttendance(ctx context.Context, userID string, happeningID string, attended bool) error
}
6 changes: 3 additions & 3 deletions apps/uno/domain/service/cms.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ func (s *CMSService) UnpinHappeningsAfterRegistrationEnd(ctx context.Context) er
if h.RegistrationEnd == nil {
continue
}

regEnd, err := time.Parse(time.RFC3339, *h.RegistrationEnd)
if err != nil {
continue
Expand All @@ -314,8 +314,8 @@ func (s *CMSService) UnpinHappeningsAfterRegistrationEnd(ctx context.Context) er
}

for _, h := range happenings {
if h.Date == nil {

if h.Date == nil {
continue
}

Expand Down
4 changes: 4 additions & 0 deletions apps/uno/domain/service/happening.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (hs *HappeningService) GetHappeningQuestions(ctx context.Context, happening
return hs.happeningRepo.GetHappeningQuestions(ctx, happeningID)
}

func (hs *HappeningService) SetAttendance(ctx context.Context, userID string, happeningID string, attended bool) error {
return hs.registrationRepo.SetAttendance(ctx, userID, happeningID, attended)
}

func (hs *HappeningService) UpdateRegistrationStatus(
ctx context.Context,
userID string,
Expand Down
2 changes: 2 additions & 0 deletions apps/uno/http/dto/happening.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ type FullRegistrationRowResponse struct {
ChangedByUser *UserResponse `json:"changedByUser"`
User UserResponse `json:"user"`
Answers []RegistrationAnswerWithQuestionResponse `json:"answers"`
Attended *bool `json:"attended"`
}

type RegistrationAnswerWithQuestionResponse struct {
Expand Down Expand Up @@ -198,6 +199,7 @@ func FullRegistrationRowsFromDomain(h model.FullHappening, usersByID map[string]
ChangedAt: reg.ChangedAt,
ChangedBy: reg.ChangedBy,
Answers: []RegistrationAnswerWithQuestionResponse{},
Attended: reg.Attended,
}

if user, ok := usersByID[reg.UserID]; ok {
Expand Down
Loading
Loading