Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

Commit

Permalink
Refactor backend for better data management and routing clarity
Browse files Browse the repository at this point in the history
This commit encompasses major backend restructuring which aims to enhance data management and routing clarity. Models and related methods have been moved from original Kotlin files to newly created repository files. As part of this refactor, unused paths in the UserRoute have been commented out. Furthermore, the 'Model.kt' file has been relocated from the model package to the repository package, and adapted to ensure seamless operation.
  • Loading branch information
daudmohamed committed Apr 6, 2024
1 parent 5f077c4 commit 3fbdc73
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 60 deletions.
4 changes: 3 additions & 1 deletion backend/app/src/main/kotlin/backend/config/Routing.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package backend.config

import backend.repository.AdminRepository
import backend.repository.ProviderRepository
import backend.repository.UserRepository
import backend.repository.WorkshopRepository
import backend.route.*
Expand All @@ -11,10 +12,11 @@ import io.ktor.server.routing.*

fun Application.configureRouting() {
val userRepository = UserRepository()
val providerRepository = ProviderRepository()
val adminRepository = AdminRepository()
val workshopRepository = WorkshopRepository()

configureAuth0Route(userRepository)
configureAuth0Route(userRepository, providerRepository)
configureUserRoutes(userRepository)
configureWorkshopRoutes(workshopRepository)
configureAdminRoutes(adminRepository)
Expand Down
43 changes: 0 additions & 43 deletions backend/app/src/main/kotlin/backend/config/TestData.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package backend.dto

import backend.model.WorkshopRegistrationState
import backend.repository.WorkshopRegistrationState
import kotlinx.serialization.Serializable

@Serializable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
package backend.repository

import backend.config.TestData
import backend.dto.AdminWorkshopDTO
import backend.dto.AdminWorkshopRegistrationDTO

class AdminRepository {
val userMap = TestData.userMap
val registrationMap = TestData.registrationMap
val workshopMap = TestData.workshopMap
/*
fun getWorkshops(): List<AdminWorkshopDTO> {
return workshopMap.map { workshop ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package backend.repository

import backend.config.TestData
import backend.dto.UserDTO
import com.inventy.plugins.DatabaseFactory.Companion.dbQuery
import org.jetbrains.exposed.dao.id.IntIdTable
Expand Down Expand Up @@ -40,8 +39,6 @@ class User(
}

class UserRepository{
val userMap = TestData.userMap

internal object UserTable : IntIdTable() {
val firstName = varchar("first_name", 256)
val lastName = varchar("last_name", 256)
Expand Down
14 changes: 9 additions & 5 deletions backend/app/src/main/resources/db/migration/V1__initial.sql
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ create table provider
provider_type varchar,
provider_id varchar,

constraint fk_provider_user foreign key (user_id) references users (id)
constraint provider_fk_user foreign key (user_id) references users (id)
);

INSERT INTO provider (user_id, provider_type, provider_id)
VALUES
('1', 'google', '123');

create table workshop
(
id int GENERATED ALWAYS AS IDENTITY primary key,
Expand All @@ -42,17 +46,17 @@ VALUES
('Building a fishy cloud datawarehouse in 2023', 'At Br Karlsen we make, buy and sell fish of all kinds, here are our experience in deploying the modern data stack , built on Airbyte, dbt , BigQuery and Apache Superset. Why we chose the components we did, and what our experience has been. When did we choose the managed version vs the open source version of a product? ', '2023-09-07T15:40', '2023-09-07T16:25', 30);



create table workshop_registration
(
id int GENERATED ALWAYS AS IDENTITY primary key,
user_id int,
workshop_id int,
state varchar
state varchar,
created_at timestamp with time zone not null default current_timestamp,
updated_at timestamp with time zone not null default current_timestamp,
constraint fk_workshop foreign key (workshop_id) references workshop (id),
constraint fk_user foreign key (user_id) references users (id)

constraint workshop_registration_fk_workshop foreign key (workshop_id) references workshop (id),
constraint workshop_registration_fk_user foreign key (user_id) references users (id)
);

INSERT INTO workshop_registration (user_id, workshop_id, state, created_at, updated_at)
Expand Down

0 comments on commit 3fbdc73

Please sign in to comment.