Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor code structure & add ÉTS API integration for courses and programs #29

Merged
merged 39 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
823ffd8
Add common folder
mhd-hi May 19, 2024
ae12b7b
Add program resource
mhd-hi May 19, 2024
b68c8e3
Fix eslint rule (complexity) & fix dependencies versions
mhd-hi May 19, 2024
c6db668
add course, cours-instance
mhd-hi May 19, 2024
1a863d6
add session resource
mhd-hi May 19, 2024
e7fc321
Add prisma, scraper, program files (modules and services)
mhd-hi May 21, 2024
606bce5
Fix prisma & add scraper files & eslint migration
mhd-hi Jun 4, 2024
932e293
chore: address sonarlint warning (if statement)
mhd-hi Jun 5, 2024
712840e
Rollback eslint flat to v8 & remove entity & format imports
mhd-hi Jun 15, 2024
83312c3
add public to classes
mhd-hi Jun 15, 2024
c691904
cleanup
mhd-hi Jun 19, 2024
c78599b
add ets api hekper files
mhd-hi Jun 19, 2024
42e7436
add ets-program logic & (WIP) upsert programs
mhd-hi Jun 22, 2024
edb4647
Remove unnecessary dtos
mhd-hi Jun 22, 2024
8df2b04
(wip 🚔) Add controllers & fix course routes
mhd-hi Jul 23, 2024
5a460d3
fix tests
mhd-hi Jul 23, 2024
f67dc26
Fix ProgramType relation
mhd-hi Jul 23, 2024
d37f8c3
Add coursePrerequisite controller & service
mhd-hi Jul 23, 2024
db78c07
Move scraper folder into /common
mhd-hi Jul 23, 2024
67c6b5a
Move pdf folder into /common
mhd-hi Jul 23, 2024
e93fac0
fix http & add prisma to app module
mhd-hi Jul 23, 2024
7351e66
fix tests (wip) & sessions route
mhd-hi Jul 24, 2024
bddcdc9
fix tests
mhd-hi Jul 24, 2024
d3db0f1
rename
mhd-hi Jul 24, 2024
1bf7bf0
Add schema image generator
mhd-hi Jul 24, 2024
bd61923
add methods
mhd-hi Jul 24, 2024
6a5160d
fix
mhd-hi Jul 24, 2024
a675fa1
change "program to programType" relation
mhd-hi Jul 24, 2024
3eb0ca0
fix ci test
mhd-hi Jul 24, 2024
64883da
miaow miaow
mhd-hi Jul 24, 2024
a616c7c
test test
mhd-hi Jul 25, 2024
4d45140
only run eslint on src folder
mhd-hi Jul 25, 2024
3af0f91
Rollback to ".test.ts" only
mhd-hi Jul 25, 2024
f0ea992
pdf small test
mhd-hi Jul 25, 2024
0f0d180
fix logging
mhd-hi Jul 26, 2024
84f24f6
fix PR & remove scraper folder
mhd-hi Jul 29, 2024
261d3ec
update enum trimester
mhd-hi Aug 3, 2024
12c81ba
remove file
mhd-hi Aug 3, 2024
eed3378
fix param
mhd-hi Aug 14, 2024
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
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
DATABASE_URL="postgresql://postgres:randompassword@localhost:5432/mydb?schema=public"
NODE_ENV=development

## if no password, use this instead:
# DATABASE_URL="postgresql://postgres@localhost:5432/mydb?schema=public"
PORT=3000

DATABASE_URL="postgresql://postgres@localhost:5432/planifetsDB?schema=public"
89 changes: 45 additions & 44 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin', 'import', 'simple-import-sort'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'airbnb-typescript/base',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js', 'dist/'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/lines-between-class-members': 'off',
complexity: ['warn', { max: 10 }],
complexity: ['error', { max: 15 }],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
overrides: {
constructors: 'no-public',
},
},
],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'prettier/prettier': [
'error',
{
endOfLine: 'lf',
},
],
indent: 'off',
'@typescript-eslint/indent': 'off',
},
};
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
project: 'tsconfig.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
plugins: ['@typescript-eslint/eslint-plugin', 'import', 'simple-import-sort'],
extends: [
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
'airbnb-typescript/base',
],
root: true,
env: {
node: true,
jest: true,
},
ignorePatterns: ['.eslintrc.js', 'dist/'],
rules: {
'@typescript-eslint/interface-name-prefix': 'off',
'@typescript-eslint/lines-between-class-members': 'off',
complexity: ['warn', { max: 10 }],
complexity: ['error', { max: 15 }],
'@typescript-eslint/explicit-member-accessibility': [
'error',
{
overrides: {
constructors: 'no-public',
},
},
],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'prettier/prettier': [
'error',
{
endOfLine: 'lf',
},
],
'@typescript-eslint/brace-style': 'off',
indent: 'off',
'@typescript-eslint/indent': 'off',
},
};
15 changes: 8 additions & 7 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
{
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"endOfLine": "lf"
}
12 changes: 6 additions & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"rvest.vs-code-prettier-eslint"
]
}
"recommendations": [
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"abians.prisma-generate-uml"
]
}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.eol": "\n"
"files.eol": "\n",
"typescript.preferences.importModuleSpecifier": "relative",
}
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "planif-ets-backend",
"name": "planifets-backend",
"version": "0.0.1",
"description": "",
"author": "",
Expand All @@ -13,7 +13,7 @@
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"lint": "eslint .",
"lint": "eslint src --ext .ts",
"refresh": "rm -rf dist && rm -rf node_modules && yarn cache clean && yarn install",
"prisma:generate": "prisma generate",
"prisma:preview": "prisma migrate dev --create-only",
Expand All @@ -35,8 +35,9 @@
"@nestjs/common": "^10.0.0",
"@nestjs/config": "^3.2.1",
"@nestjs/core": "^10.0.0",
"@nestjs/mapped-types": "^2.0.5",
"@nestjs/platform-express": "^10.0.0",
"@prisma/client": "^5.7.1",
"@prisma/client": "^5.15.0",
"axios": "^1.6.8",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
Expand Down Expand Up @@ -69,6 +70,7 @@
"prettier": "^3.2.5",
"prettier-eslint": "^16.3.0",
"prisma": "^5.7.1",
"prisma-erd-generator": "^1.11.2",
"source-map-support": "^0.5.21",
"supertest": "^6.3.3",
"ts-jest": "^29.1.0",
Expand All @@ -95,4 +97,4 @@
"coverageDirectory": "../coverage",
"testEnvironment": "node"
}
}
}
1 change: 1 addition & 0 deletions prisma/ERD.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Warnings:

- You are about to drop the column `abbreviation` on the `Program` table. All the data in the column will be lost.
- You are about to drop the column `type` on the `Program` table. All the data in the column will be lost.
- A unique constraint covering the columns `[code,title]` on the table `Program` will be added. If there are existing duplicate values, this will fail.

*/
-- AlterTable
ALTER TABLE "Program" DROP COLUMN "abbreviation",
DROP COLUMN "type",
ADD COLUMN "types" INTEGER[];

-- CreateTable
CREATE TABLE "ProgramType" (
"id" INTEGER NOT NULL,
"title" TEXT NOT NULL,

CONSTRAINT "ProgramType_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "Program_code_title_key" ON "Program"("code", "title");
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Warnings:

- You are about to drop the column `unstructuredPrerequisites` on the `Course` table. All the data in the column will be lost.
- You are about to drop the column `types` on the `Program` table. All the data in the column will be lost.
- You are about to drop the column `name` on the `Session` table. All the data in the column will be lost.
- Added the required column `programTypeId` to the `Program` table without a default value. This is not possible if the table is not empty.
- Added the required column `trimester` to the `Session` table without a default value. This is not possible if the table is not empty.

*/
-- CreateEnum
CREATE TYPE "Trimester" AS ENUM ('A', 'E', 'H');

-- AlterTable
ALTER TABLE "Course" DROP COLUMN "unstructuredPrerequisites";

-- AlterTable
ALTER TABLE "Program" DROP COLUMN "types",
ADD COLUMN "programTypeId" INTEGER NOT NULL;

-- AlterTable
CREATE SEQUENCE programtype_id_seq;
ALTER TABLE "ProgramType" ALTER COLUMN "id" SET DEFAULT nextval('programtype_id_seq');
ALTER SEQUENCE programtype_id_seq OWNED BY "ProgramType"."id";

-- AlterTable
ALTER TABLE "Session" DROP COLUMN "name",
ADD COLUMN "trimester" "Trimester" NOT NULL;

-- CreateIndex
CREATE INDEX "Program_programTypeId_idx" ON "Program"("programTypeId");

-- AddForeignKey
ALTER TABLE "Program" ADD CONSTRAINT "Program_programTypeId_fkey" FOREIGN KEY ("programTypeId") REFERENCES "ProgramType"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
Warnings:

- You are about to drop the column `programTypeId` on the `Program` table. All the data in the column will be lost.

*/
-- DropForeignKey
ALTER TABLE "Program" DROP CONSTRAINT "Program_programTypeId_fkey";

-- DropIndex
DROP INDEX "Program_programTypeId_idx";

-- AlterTable
ALTER TABLE "Program" DROP COLUMN "programTypeId",
ADD COLUMN "programTypeIds" TEXT NOT NULL DEFAULT '[]';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
Warnings:

- Added the required column `cycle` to the `Program` table without a default value. This is not possible if the table is not empty.
- Changed the type of `programTypeIds` on the `Program` table. No cast exists, the column would be dropped and recreated, which cannot be done if there is data, since the column is required.

*/
-- AlterTable
ALTER TABLE "Program" ADD COLUMN "cycle" INTEGER NOT NULL,
ALTER COLUMN "credits" SET DATA TYPE TEXT,
DROP COLUMN "programTypeIds",
ADD COLUMN "programTypeIds" JSONB NOT NULL;

-- AlterTable
ALTER TABLE "ProgramType" ALTER COLUMN "id" DROP DEFAULT;
DROP SEQUENCE "programtype_id_seq";
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
Warnings:

- The values [A,E,H] on the enum `Trimester` will be removed. If these variants are still used in the database, this will fail.

*/
-- AlterEnum
BEGIN;
CREATE TYPE "Trimester_new" AS ENUM ('AUTOMNE', 'ETE', 'HIVER');
ALTER TABLE "Session" ALTER COLUMN "trimester" TYPE "Trimester_new" USING ("trimester"::text::"Trimester_new");
ALTER TYPE "Trimester" RENAME TO "Trimester_old";
ALTER TYPE "Trimester_new" RENAME TO "Trimester";
DROP TYPE "Trimester_old";
COMMIT;
Loading
Loading