Skip to content

Commit

Permalink
incrementing ids; student/tutor to event relation
Browse files Browse the repository at this point in the history
  • Loading branch information
dheidemann committed Jul 3, 2024
1 parent 948bdfe commit 45e640e
Show file tree
Hide file tree
Showing 17 changed files with 664 additions and 767 deletions.
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ services:
restart: always
volumes:
- data:/var/lib/postgresql/data
- ./server/init.sql:/docker-entrypoint-initdb.d/init.sql
env_file: .env.local
server:
build:
Expand Down
48 changes: 23 additions & 25 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# GraphQL Schema Documentation

This document describes the queries and mutations available in the GraphQL schema, along with example requests.

**Note: Not all queries and mutations are implemented yet**

## Queries
Expand Down Expand Up @@ -34,12 +32,12 @@ query {
Fetches a list of tutors by email and event ID.
#### Arguments:
- `mail: [String!]` (optional) - List of emails to filter tutors.
- `eventID: UUID` (optional) - Event ID to filter tutors.
- `eventID: Int` (optional) - Event ID to filter tutors.

#### Example:
```graphql
query {
tutors(mail: ["[email protected]"], eventID: "123e4567-e89b-12d3-a456-426614174000") {
tutors(mail: ["[email protected]"], eventID: 1) {
fn
sn
mail
Expand All @@ -59,14 +57,14 @@ query {
### `events`
Fetches a list of events by ID and topic.
#### Arguments:
- `id: [UUID!]` (optional) - List of event IDs to filter events.
- `id: [Int!]` (optional) - List of event IDs to filter events.
- `topic: [String!]` (optional) - List of topics to filter events.
- `needsTutors: Boolean` (optional) - Filter events whether it needs tutors.

#### Example:
```graphql
query {
events(id: ["123e4567-e89b-12d3-a456-426614174000"], topic: ["Math"], needsTutors: true) {
events(id: [1], topic: ["Math"], needsTutors: true) {
ID
title
description
Expand Down Expand Up @@ -103,12 +101,12 @@ query {
### `buildings`
Fetches a list of buildings by ID.
#### Arguments:
- `id: [UUID!]` (optional) - List of building IDs to filter buildings.
- `id: [Int!]` (optional) - List of building IDs to filter buildings.

#### Example:
```graphql
query {
buildings(id: ["123e4567-e89b-12d3-a456-426614174000"]) {
buildings(id: [1]) {
ID
name
street
Expand All @@ -128,12 +126,12 @@ query {
Fetches a list of rooms by number and building ID.
#### Arguments:
- `number: [String!]` (optional) - List of room numbers to filter rooms.
- `buildingID: UUID!` - Building ID where rooms are located.
- `buildingID: Int!` - Building ID where rooms are located.

#### Example:
```graphql
query {
rooms(number: ["101", "102"], buildingID: "123e4567-e89b-12d3-a456-426614174000") {
rooms(number: ["101", "102"], buildingID: 1) {
number
name
capacity
Expand Down Expand Up @@ -207,7 +205,7 @@ mutation {
fn: "Jane"
sn: "Doe"
mail: "[email protected]"
eventsAvailable: ["123e4567-e89b-12d3-a456-426614174000"]
eventsAvailable: [1]
})
}
```
Expand All @@ -225,7 +223,7 @@ mutation {
fn: "Jane"
sn: "Doe"
mail: "[email protected]"
eventsAvailable: ["123e4567-e89b-12d3-a456-426614174000"]
eventsAvailable: [1]
})
}
```
Expand All @@ -244,29 +242,29 @@ mutation {
topicName: "Math"
link: "http://example.com"
needsTutors: true
from: "09:00:00"
to: "11:00:00"
from: "2023-07-03T09:00:00Z"
to: "2023-07-03T11:00:00Z"
})
}
```

### ~~`updateEvent`~~
Updates an event's details.
#### Arguments:
- `eventID: UUID!` - ID of the event.
- `eventID: Int!` - ID of the event.
- `event: NewEvent!` - Updated details of the event.

#### Example:
```graphql
mutation {
updateEvent(eventID: "123e4567-e89b-12d3-a456-426614174000", event: {
updateEvent(eventID: 1, event: {
title: "Advanced Math Tutoring"
description: "Advanced tutoring session for Math"
topicName: "Math"
link: "http://example.com"
needsTutors: true
from: "10:00:00"
to: "12:00:00"
from: "2023-07-03T10:00:00Z"
to: "2023-07-03T12:00:00Z"
})
}
```
Expand Down Expand Up @@ -303,21 +301,21 @@ mutation {
name: "Physics Lab"
capacity: 30
floor: 1
buildingID: "123e4567-e89b-12d3-a456-426614174000"
buildingID: 1
})
}
```

### ~~`updateBuilding`~~
Updates a building's details.
#### Arguments:
- `buildingID: UUID!` - ID of the building.
- `buildingID: Int!` - ID of the building.
- `building: NewBuilding!` - Updated details of the building.

#### Example:
```graphql
mutation {
updateBuilding(buildingID: "123e4567-e89b-12d3-a456-426614174000", building: {
updateBuilding(buildingID: 1, building: {
name: "Science Building"
street: "123 Main St"
number: "1"
Expand Down Expand Up @@ -352,9 +350,9 @@ Links an available room to an event.
```graphql
mutation {
linkAvailableRoomToEvent(link: {
eventID: "123e4567-e89b-12d3-a456-426614174000"
eventID: 1
roomNumber: "101"
buildingID: "123e4567-e89b-12d3-a456-426614174000"
buildingID: 1
})
}
```
Expand All @@ -368,10 +366,10 @@ Links a tutor to an event and room.
```graphql
mutation {
linkTutorToEventAndRoom(link: {
eventID: "123e4567-e89b-12d3-a456-426614174000"
eventID: 1
tutorMail: "[email protected]"
roomNumber: "101"
buildingID: "123e4567-e89b-12d3-a456-426614174000"
buildingID: 1
})
}
```
5 changes: 3 additions & 2 deletions server/db/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ func Init(ctx context.Context) (*bun.DB, *sql.DB, error) {
db.AddQueryHook(bundebug.NewQueryHook(bundebug.WithVerbose(true)))

relations := []interface{}{
(*models.EventToRoom)(nil),
(*models.EventToTutor)(nil),
(*models.UserToEvent)(nil),
(*models.TutorToEvent)(nil),
(*models.StudentToEvent)(nil),
(*models.RoomToEvent)(nil),
}

for _, relation := range relations {
Expand Down
2 changes: 1 addition & 1 deletion server/email/send.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func SendConfirmation(person models.User) error {
Color: "#990000",
Text: "E-Mail bestätigen",
Link: fmt.Sprintf("%s/confirm/%s",
os.Getenv("API_URL"), person.SessionID),
os.Getenv("API_URL"), strconv.Itoa(person.SessionID)),
},
},
},
Expand Down
2 changes: 1 addition & 1 deletion server/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ go 1.22.4
require (
github.com/99designs/gqlgen v0.17.49
github.com/go-chi/chi/v5 v5.0.14
github.com/google/uuid v1.6.0
github.com/matcornic/hermes/v2 v2.1.0
github.com/robfig/cron/v3 v3.0.1
github.com/rs/cors v1.11.0
Expand All @@ -26,6 +25,7 @@ require (
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/css v1.0.1 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
Expand Down
8 changes: 7 additions & 1 deletion server/gqlgen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ resolver:
# Optional: turn on to not generate template comments above resolvers
# omit_template_comment: false

omit_getters: true

# Optional: turn on use ` + "`" + `gqlgen:"fieldName"` + "`" + ` tags in your models
# struct_tag: json

Expand Down Expand Up @@ -97,6 +99,10 @@ models:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Tutor
NewTutor:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Tutor
Student:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Student
NewStudent:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Student
Topic:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Topic
NewTopic:
Expand All @@ -106,6 +112,6 @@ models:
NewRoom:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.Room
NewRoomToEventLink:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.EventToRoom
model: github.com/FachschaftMathPhysInfo/pepp/server/models.RoomToEvent
NewEventToTutorLink:
model: github.com/FachschaftMathPhysInfo/pepp/server/models.EventToTutor
Loading

0 comments on commit 45e640e

Please sign in to comment.