Skip to content

Commit

Permalink
Merge branch 'main' into add-frontend-api
Browse files Browse the repository at this point in the history
  • Loading branch information
mgtennant committed Jun 12, 2024
2 parents 690dcf1 + 97a957f commit ea0a366
Show file tree
Hide file tree
Showing 18 changed files with 351 additions and 39 deletions.
38 changes: 32 additions & 6 deletions backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,15 +1,41 @@
generator client {
provider = "prisma-client-js"
provider = "prisma-client-js"
previewFeatures = ["metrics"]
}

datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
url = env("POSTGRESQL_URL")
}

model users {
id Decimal @id(map: "USER_PK") @default(dbgenerated("nextval('\"USER_SEQ\"'::regclass)")) @db.Decimal
name String @db.VarChar(200)
email String @db.VarChar(200)
/// This model or at least one of its fields has comments in the database, and requires an additional setup for migrations: Read more: https://pris.ly/d/database-comments
model submission_status_code {
submission_status_code String @id(map: "submission_status_code_pk") @db.VarChar(20)
description String @db.VarChar(250)
display_order Int
active_ind Boolean @default(true)
create_user_id String @db.VarChar(200)
create_utc_timestamp DateTime @db.Timestamp(6)
update_user_id String @db.VarChar(200)
update_utc_timestamp DateTime @db.Timestamp(6)
file_submissions_file_submissions_submission_status_codeTosubmission_status_code file_submissions[] @relation("file_submissions_submission_status_codeTosubmission_status_code")
}

model file_submissions {
submission_id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
file_name String @db.VarChar(200)
submission_date DateTime @db.Timestamp(6)
submitter_user_id String @db.VarChar(200)
submission_status_code String @db.VarChar(10)
submitter_agency_name String @db.VarChar(200)
sample_count Int?
results_count Int?
active_ind Boolean @default(true)
error_log String?
organization_guid String? @db.Uuid
create_user_id String @db.VarChar(200)
create_utc_timestamp DateTime @db.Timestamp(6)
update_user_id String @db.VarChar(200)
update_utc_timestamp DateTime @db.Timestamp(6)
submission_status_code_file_submissions_submission_status_codeTosubmission_status_code submission_status_code @relation("file_submissions_submission_status_codeTosubmission_status_code", fields: [submission_status_code], references: [submission_status_code], onDelete: NoAction, onUpdate: NoAction, map: "submission_status_code_fk")
}
2 changes: 2 additions & 0 deletions backend/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { TerminusModule } from "@nestjs/terminus";
import { HealthController } from "./health.controller";
import { JWTAuthModule } from "./auth/jwtauth.module";
import { AdminModule } from "./admin/admin.module";
import { DryrunModule } from "./dryrun/dryrun.module";

const DB_HOST = process.env.POSTGRES_HOST || "localhost";
const DB_USER = process.env.POSTGRES_USER || "postgres";
Expand Down Expand Up @@ -52,6 +53,7 @@ function getMiddlewares() {
middlewares: getMiddlewares(),
},
}),
DryrunModule,
JWTAuthModule,
AdminModule,
],
Expand Down
20 changes: 20 additions & 0 deletions backend/src/dryrun/dryrun.controller.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Test, TestingModule } from '@nestjs/testing';
import { DryrunController } from './dryrun.controller';
import { DryrunService } from './dryrun.service';

describe('DryrunController', () => {
let controller: DryrunController;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
controllers: [DryrunController],
providers: [DryrunService],
}).compile();

controller = module.get<DryrunController>(DryrunController);
});

it('should be defined', () => {
expect(controller).toBeDefined();
});
});
39 changes: 39 additions & 0 deletions backend/src/dryrun/dryrun.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common';
import { DryrunService } from './dryrun.service';
import { CreateDryrunDto } from './dto/create-dryrun.dto';
import { UpdateDryrunDto } from './dto/update-dryrun.dto';
import { ApiTags } from '@nestjs/swagger';
import { DryrunDto } from './dto/dryrun.dto';

@ApiTags("dryrun")
@Controller({path: "dryrun", version: "1"})
export class DryrunController {
constructor(private readonly dryrunService: DryrunService) {}

@Post()
create(@Body() createDryrunDto: CreateDryrunDto) {
console.log("I AM HERE!!!");
return this.dryrunService.create(createDryrunDto);
}

@Get()
findAll() {
console.log('FIND ALL HERE!!!')
return this.dryrunService.findAll();
}

@Get(':id')
findOne(@Param('id') id: string) {
return this.dryrunService.findOne(+id);
}

@Patch(':id')
update(@Param('id') id: string, @Body() updateDryrunDto: UpdateDryrunDto) {
return this.dryrunService.update(+id, updateDryrunDto);
}

@Delete(':id')
remove(@Param('id') id: string) {
return this.dryrunService.remove(+id);
}
}
9 changes: 9 additions & 0 deletions backend/src/dryrun/dryrun.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Module } from '@nestjs/common';
import { DryrunService } from './dryrun.service';
import { DryrunController } from './dryrun.controller';

@Module({
controllers: [DryrunController],
providers: [DryrunService],
})
export class DryrunModule {}
18 changes: 18 additions & 0 deletions backend/src/dryrun/dryrun.service.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Test, TestingModule } from '@nestjs/testing';
import { DryrunService } from './dryrun.service';

describe('DryrunService', () => {
let service: DryrunService;

beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [DryrunService],
}).compile();

service = module.get<DryrunService>(DryrunService);
});

it('should be defined', () => {
expect(service).toBeDefined();
});
});
36 changes: 36 additions & 0 deletions backend/src/dryrun/dryrun.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { Injectable } from '@nestjs/common';
import { CreateDryrunDto } from './dto/create-dryrun.dto';
import { UpdateDryrunDto } from './dto/update-dryrun.dto';
import { PrismaService } from 'nestjs-prisma';
import { Prisma } from "@prisma/client";
import { DryrunDto } from './dto/dryrun.dto';

@Injectable()
export class DryrunService {
constructor(
private prisma: PrismaService
) {
}

create(createDryrunDto: CreateDryrunDto) {
console.log("I WILL SEND THE POST FROM HERE!!!");
return 'This action adds a new dryrun';
}

async findAll() {
const files = await this.prisma.file_submissions.findMany();
console.log(files)
}

findOne(id: number) {
return `This action returns a #${id} dryrun`;
}

update(id: number, updateDryrunDto: UpdateDryrunDto) {
return `This action updates a #${id} dryrun`;
}

remove(id: number) {
return `This action removes a #${id} dryrun`;
}
}
13 changes: 13 additions & 0 deletions backend/src/dryrun/dto/create-dryrun.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { PickType } from "@nestjs/swagger";
import { DryrunDto } from "./dryrun.dto";

export class CreateDryrunDto extends PickType(DryrunDto, [
'submission_status_code',
'description',
'display_order',
'active_ind',
'create_user_id',
'create_utc_timestamp',
'update_user_id',
'update_utc_timestamp',
] as const) {}
46 changes: 46 additions & 0 deletions backend/src/dryrun/dto/dryrun.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { ApiProperty } from '@nestjs/swagger';

export class DryrunDto {
@ApiProperty({
description: 'Unique identifies for the submitted file',
// default: '9999',
})
submission_status_code: string;

@ApiProperty({
description: 'Full name of the code',
// default: 'username',
})
description: string;

@ApiProperty({
description: 'Order in which the code appears',
})
display_order: number;

@ApiProperty({
description: 'True if active, false otherwise',
default: true,
})
active_ind: boolean

@ApiProperty({
description: 'The id of the user that created the record',
})
create_user_id: string;

@ApiProperty({
description: 'When the user created the record',
})
create_utc_timestamp: Date;

@ApiProperty({
description: 'The id of the user that last updated the record',
})
update_user_id: string;

@ApiProperty({
description: 'When the user last updated the record',
})
update_utc_timestamp: Date;
}
3 changes: 3 additions & 0 deletions backend/src/dryrun/dto/update-dryrun.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { CreateDryrunDto } from './create-dryrun.dto';

export class UpdateDryrunDto extends CreateDryrunDto {}
1 change: 1 addition & 0 deletions backend/src/dryrun/entities/dryrun.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Dryrun {}
9 changes: 7 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ x-var:
default
- &POSTGRES_DATABASE
postgres
- &POSTGRES_HOST
localhost:5432
- &POSTGRES_SCHEMA
ENMODS

x-postgres-vars: &postgres-vars
POSTGRES_HOST: database
POSTGRES_HOST: *POSTGRES_HOST
POSTGRES_USER: *POSTGRES_USER
POSTGRES_PASSWORD: *POSTGRES_PASSWORD
POSTGRES_DATABASE: *POSTGRES_DATABASE
POSTGRES_SCHEMA: *POSTGRES_SCHEMA

services:
database:
Expand All @@ -35,7 +40,7 @@ services:
FLYWAY_USER: *POSTGRES_USER
FLYWAY_PASSWORD: *POSTGRES_PASSWORD
FLYWAY_BASELINE_ON_MIGRATE: true
FLYWAY_DEFAULT_SCHEMA: USERS
FLYWAY_DEFAULT_SCHEMA: *POSTGRES_SCHEMA
depends_on:
database:
condition: service_healthy
Expand Down
18 changes: 12 additions & 6 deletions frontend/package-lock.json

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

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"react-drag-drop-files": "^2.3.10",
"react-router": "^6.12.1",
"react-router-dom": "^6.12.1",
"redux": "^5.0.1",
"vite": "^5.0.0",
"vite-tsconfig-paths": "^4.2.0"
},
Expand Down
24 changes: 0 additions & 24 deletions migrations/sql/V1.0.0__init.sql

This file was deleted.

Loading

0 comments on commit ea0a366

Please sign in to comment.