Skip to content

Commit

Permalink
feat(rooms): add room report endpoints (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert27 authored Oct 28, 2024
1 parent 2712898 commit 73dff82
Show file tree
Hide file tree
Showing 20 changed files with 598 additions and 41 deletions.
3 changes: 2 additions & 1 deletion .env.local.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ DB_HOST=localhost
DB_PORT=5432
POSTGRES_DB=app
POSTGRES_USER=postgres
POSTGRES_PASSWORD=""
POSTGRES_PASSWORD=""
BYPASS_AUTH_IN_DEV=false
Binary file modified bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"start": "bun run index.ts",
"dev": "bun --hot run index.ts",
"prepare": "husky",
"docs": "concurrently --kill-others --success first \"cross-env PORT=4321 bun run start\" \"bunx spectaql ./documentation/config.yml\"",
"docs": "concurrently --kill-others --success first \"cross-env PORT=4321 npm run start\" \"npx spectaql ./documentation/config.yml\"",
"drizzle-kit": "drizzle-kit generate --schema ./src/db/schema/ --dialect postgresql --out ./src/db/migrations",
"migrate": "bun run ./src/db/migrate.ts"
},
Expand Down
9 changes: 9 additions & 0 deletions src/db/migrations/0005_lowly_albert_cleary.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE TYPE "public"."room_report_reason" AS ENUM('WRONG_DESCRIPTION', 'WRONG_LOCATION', 'NOT_EXISTING', 'MISSING', 'OTHER');--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "room_reports" (
"id" serial PRIMARY KEY NOT NULL,
"room" text NOT NULL,
"reason" "room_report_reason" NOT NULL,
"description" text NOT NULL,
"created_at" timestamp with time zone NOT NULL,
"resolved_at" timestamp with time zone
);
320 changes: 320 additions & 0 deletions src/db/migrations/meta/0005_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,320 @@
{
"id": "b85d110e-f795-46a3-8090-99928653875b",
"prevId": "6ba274fb-ed5a-49b7-9f98-ac5a167cbf68",
"version": "7",
"dialect": "postgresql",
"tables": {
"public.app_announcements": {
"name": "app_announcements",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"title_de": {
"name": "title_de",
"type": "text",
"primaryKey": false,
"notNull": true
},
"title_en": {
"name": "title_en",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description_de": {
"name": "description_de",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description_en": {
"name": "description_en",
"type": "text",
"primaryKey": false,
"notNull": true
},
"start_date_time": {
"name": "start_date_time",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"end_date_time": {
"name": "end_date_time",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"priority": {
"name": "priority",
"type": "integer",
"primaryKey": false,
"notNull": true
},
"url": {
"name": "url",
"type": "text",
"primaryKey": false,
"notNull": false
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.room_reports": {
"name": "room_reports",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"room": {
"name": "room",
"type": "text",
"primaryKey": false,
"notNull": true
},
"reason": {
"name": "reason",
"type": "room_report_reason",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"resolved_at": {
"name": "resolved_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
},
"public.university_sports": {
"name": "university_sports",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "serial",
"primaryKey": true,
"notNull": true
},
"title_de": {
"name": "title_de",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description_de": {
"name": "description_de",
"type": "text",
"primaryKey": false,
"notNull": false
},
"title_en": {
"name": "title_en",
"type": "text",
"primaryKey": false,
"notNull": true
},
"description_en": {
"name": "description_en",
"type": "text",
"primaryKey": false,
"notNull": false
},
"campus": {
"name": "campus",
"type": "campus",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"location": {
"name": "location",
"type": "text",
"primaryKey": false,
"notNull": true
},
"weekday": {
"name": "weekday",
"type": "weekday",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"start_time": {
"name": "start_time",
"type": "time",
"primaryKey": false,
"notNull": true
},
"end_time": {
"name": "end_time",
"type": "time",
"primaryKey": false,
"notNull": false
},
"requires_registration": {
"name": "requires_registration",
"type": "boolean",
"primaryKey": false,
"notNull": true
},
"invitation_link": {
"name": "invitation_link",
"type": "text",
"primaryKey": false,
"notNull": false
},
"e_mail": {
"name": "e_mail",
"type": "text",
"primaryKey": false,
"notNull": false
},
"sports_category": {
"name": "sports_category",
"type": "sports_category",
"typeSchema": "public",
"primaryKey": false,
"notNull": true
},
"created_at": {
"name": "created_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
},
"updated_at": {
"name": "updated_at",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {},
"checkConstraints": {}
}
},
"enums": {
"public.room_report_reason": {
"name": "room_report_reason",
"schema": "public",
"values": [
"WRONG_DESCRIPTION",
"WRONG_LOCATION",
"NOT_EXISTING",
"MISSING",
"OTHER"
]
},
"public.campus": {
"name": "campus",
"schema": "public",
"values": ["Ingolstadt", "Neuburg"]
},
"public.sports_category": {
"name": "sports_category",
"schema": "public",
"values": [
"Basketball",
"Soccer",
"Calisthenics",
"Dancing",
"StrengthTraining",
"Running",
"Jogging",
"Handball",
"Frisbee",
"Volleyball",
"Spikeball",
"FullBodyWorkout",
"Defense",
"Yoga",
"Meditation",
"Tennis",
"Badminton",
"Swimming",
"Waterpolo",
"Cycling",
"Climbing",
"Boxing",
"Kickboxing",
"MartialArts",
"TableTennis",
"Rowing",
"Baseball",
"Skateboarding",
"Parkour",
"Hockey",
"Hiking",
"Other"
]
},
"public.weekday": {
"name": "weekday",
"schema": "public",
"values": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday"
]
}
},
"schemas": {},
"sequences": {},
"views": {},
"_meta": {
"columns": {},
"schemas": {},
"tables": {}
}
}
7 changes: 7 additions & 0 deletions src/db/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@
"when": 1728979979516,
"tag": "0004_wet_lady_deathstrike",
"breakpoints": true
},
{
"idx": 5,
"version": "7",
"when": 1730114334704,
"tag": "0005_lowly_albert_cleary",
"breakpoints": true
}
]
}
7 changes: 6 additions & 1 deletion src/db/schema/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import * as appAnnouncements from '@/db/schema/appAnnouncements'
import * as roomReports from '@/db/schema/roomReports'
import * as universitySports from '@/db/schema/universitySports'

export default { ...appAnnouncements, ...universitySports }
export default {
...appAnnouncements,
...universitySports,
...roomReports,
}
18 changes: 18 additions & 0 deletions src/db/schema/roomReports.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { pgEnum, pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core'

export const roomReportReason = pgEnum('room_report_reason', [
'WRONG_DESCRIPTION',
'WRONG_LOCATION',
'NOT_EXISTING',
'MISSING',
'OTHER',
])

export const roomReports = pgTable('room_reports', {
id: serial('id').primaryKey(),
room: text('room').notNull(),
reason: roomReportReason('reason').notNull(),
description: text('description').notNull(),
created_at: timestamp('created_at', { withTimezone: true }).notNull(),
resolved_at: timestamp('resolved_at', { withTimezone: true }),
})
Loading

0 comments on commit 73dff82

Please sign in to comment.