Skip to content

solved ESPR #2

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
112 changes: 109 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,58 @@ The backend is an Express application written in TypeScript. The src directory c

The `prisma` directory contains the Prisma schema.

## API Endpoints

The backend provides the following API endpoints:

### Candidates
- `GET /candidates/:id` - Get a candidate by ID
- `POST /candidates` - Add a new candidate
- `PUT /candidates/:id/stage` - Update a candidate's interview stage

### Positions
- `GET /positions/:id/candidates` - Get all candidates in process for a specific position

### Other
- `POST /upload` - Upload a file

Example request for updating a candidate's stage:
```
PUT http://localhost:3010/candidates/1/stage
{
"interviewStepId": 2
}
```

Example response:
```
{
"message": "Etapa del candidato actualizada correctamente",
"current_interview_step": "Technical Interview"
}
```

Example request for getting candidates for a position:
```
GET http://localhost:3010/positions/1/candidates
```

Example response:
```
[
{
"fullName": "John Doe",
"current_interview_step": "Technical Interview",
"average_score": 5
},
{
"fullName": "Jane Smith",
"current_interview_step": "Technical Interview",
"average_score": 4
}
]
```

## First steps

To get started with this project, follow these steps:
Expand All @@ -62,7 +114,7 @@ npm install
```
cd backend
npm run build
````
```
4. Start the backend server:
```
cd backend
Expand Down Expand Up @@ -111,7 +163,7 @@ docker-compose down
```
To generate the database using Prisma, follow these steps:

1. Make sure that the .env file in the root directory of the backend contains the DATABASE_URL variable with the correct connection string to your PostgreSQL database. If it doesnt work, try replacing the full URL directly in schema.prisma, in the url variable.
1. Make sure that the .env file in the root directory of the backend contains the DATABASE_URL variable with the correct connection string to your PostgreSQL database. If it doesn't work, try replacing the full URL directly in schema.prisma, in the url variable.

2. Open a terminal and navigate to the backend directory where the schema.prisma and seed.ts files are located.

Expand All @@ -125,6 +177,7 @@ ts-node seed.ts

Once you have completed all the steps, you should be able to save new candidates, both via web and via API, view them in the database, and retrieve them using GET by ID.

Example for adding a new candidate:
```
POST http://localhost:3010/candidates
{
Expand Down Expand Up @@ -205,6 +258,58 @@ El backend es una aplicación Express escrita en TypeScript. El directorio `src`

El directorio `prisma` contiene el esquema de Prisma.

## Endpoints de la API

El backend proporciona los siguientes endpoints de API:

### Candidatos
- `GET /candidates/:id` - Obtener un candidato por ID
- `POST /candidates` - Añadir un nuevo candidato
- `PUT /candidates/:id/stage` - Actualizar la etapa de entrevista de un candidato

### Posiciones
- `GET /positions/:id/candidates` - Obtener todos los candidatos en proceso para una posición específica

### Otros
- `POST /upload` - Subir un archivo

Ejemplo de solicitud para actualizar la etapa de un candidato:
```
PUT http://localhost:3010/candidates/1/stage
{
"interviewStepId": 2
}
```

Ejemplo de respuesta:
```
{
"message": "Etapa del candidato actualizada correctamente",
"current_interview_step": "Technical Interview"
}
```

Ejemplo de solicitud para obtener candidatos de una posición:
```
GET http://localhost:3010/positions/1/candidates
```

Ejemplo de respuesta:
```
[
{
"fullName": "John Doe",
"current_interview_step": "Technical Interview",
"average_score": 5
},
{
"fullName": "Jane Smith",
"current_interview_step": "Technical Interview",
"average_score": 4
}
]
```

## Primeros Pasos

Para comenzar con este proyecto, sigue estos pasos:
Expand All @@ -222,7 +327,7 @@ npm install
```
cd backend
npm run build
````
```
4. Inicia el servidor backend:
```
cd backend
Expand Down Expand Up @@ -282,6 +387,7 @@ ts-node seed.ts

Una vez has dado todos los pasos, deberías poder guardar nuevos candidatos, tanto via web, como via API, verlos en la base de datos y obtenerlos mediante GET por id.

Ejemplo para añadir un nuevo candidato:
```
POST http://localhost:3010/candidates
{
Expand Down
19 changes: 10 additions & 9 deletions backend/package-lock.json

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

2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/express": "^4.17.9",
"@types/jest": "^29.5.12",
"@types/multer": "^1.4.11",
"@types/node": "^20.12.12",
"@types/node": "^20.17.30",
"eslint": "^9.2.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
Expand Down
36 changes: 36 additions & 0 deletions backend/prisma/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { PrismaClient } from '@prisma/client';

const prisma = new PrismaClient();

async function main() {
console.log('Consultando posiciones...');
const positions = await prisma.position.findMany();
console.log('Posiciones:', positions.map(p => ({ id: p.id, title: p.title })));

console.log('\nConsultando aplicaciones...');
const applications = await prisma.application.findMany({
include: {
position: true,
candidate: true,
interviewStep: true
}
});

console.log('Aplicaciones:', applications.map(a => ({
id: a.id,
positionId: a.positionId,
positionTitle: a.position.title,
candidateId: a.candidateId,
candidateName: `${a.candidate.firstName} ${a.candidate.lastName}`,
currentStep: a.interviewStep.name
})));
}

main()
.catch((e) => {
console.error(e);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});
Loading