-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from adrianrbp/2-companyservice-shift-management
company service shift management
- Loading branch information
Showing
55 changed files
with
2,489 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: test | ||
|
||
on: push | ||
|
||
jobs: | ||
backend: | ||
name: 'Rails API Tests' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: '3.3.4' | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd backend | ||
bundle install | ||
- name: Run Rails tests | ||
run: | | ||
cd backend | ||
bin/rails test | ||
frontend: | ||
name: 'Vue Frontend Tests' | ||
runs-on: ubuntu-latest | ||
needs: backend # Ensure frontend tests run after backend tests | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '21' | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd frontend | ||
yarn install | ||
- name: Run Jest tests | ||
run: | | ||
cd frontend | ||
yarn test:unit | ||
# - name: Start Rails server | ||
# run: | | ||
# cd backend | ||
# bin/rails server -e test & # Run the server in the background | ||
|
||
# - name: Wait for Rails server to be ready | ||
# run: | | ||
# until curl -s http://localhost:3000 > /dev/null; do | ||
# echo "Waiting for Rails server..." | ||
# sleep 2 | ||
# done | ||
|
||
end-to-end: | ||
name: 'End to End Tests' | ||
runs-on: ubuntu-latest | ||
container: | ||
image: mcr.microsoft.com/playwright:v1.45.1-jammy | ||
needs: [backend, frontend] | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: | | ||
cd frontend | ||
yarn install | ||
# - name: Install Playwright Browsers | ||
# run: npx playwright install --with-deps | ||
|
||
- name: Run Playwright tests | ||
run: | | ||
cd frontend | ||
yarn test:e2e | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
## Monitoring Schedule | ||
|
||
### Resumen | ||
- Contexto: | ||
- Coordinar los turnos de guardia para cada servicio monitoreado por semana | ||
|
||
- Sistema que permite: | ||
- Indicar la **disponibilidad de tiempo en la semana** de cada ingeniero del equipo | ||
- **Asignar a ingenieros a turnos** de monitoreo de servicios. | ||
- Visualizar los turnos asignados | ||
#### Features | ||
1. Gestión de Turnos: | ||
- Facilita la visualización de los turnos asignados | ||
- Asegura que la información sobre las horas sin asignar sea clara y accesible. | ||
2. Gestión de Disponibilidad: | ||
- Permite a los ingenieros | ||
1. Seleccionar el servicio y la semana, | ||
2. Visualizar su disponibilidad | ||
3. Marcar su disponibilidad. | ||
### Modo de uso: | ||
1. Los ingenieros se reunen para organizar su disponibilidad y turnos | ||
2. Se revisa los turnos indicados por el servicio de empresa para esa semana | ||
3. Se pasa a consultar a cada ingeniero (segun el servicio que le toca esa semana) su disponibilidad para esa semana. Al finalizar se presiona en "Guardar". | ||
4. Se regresa a revisar los turnos asignados automaticamente para la semana segun el servicio. | ||
|
||
### Componentes | ||
#### Endpoints - Gestion de Turnos (Shifts) | ||
- 1st Dropdown (Services) | ||
- /api/company_services | ||
- 2nd Dropdown (Weeks) | ||
- /api/company_services/:id/weeks | ||
- Engineers Table | ||
- /api/company_services/:id/engineers?week=YYYY-WW | ||
- Shifts Table | ||
- /api/company_services/:id/shifts?week=YYYY-WW | ||
#### Endpoints - Gestion de Disponibilidad (Availability) | ||
- Los de gestion de turnos para el filtrado y llenado de semana | ||
- Updates Engineer Availability | ||
- /api/company_services/:id/engineers/availability | ||
- week | ||
- availability (array) | ||
- engineer_id | ||
- time_blocks (array) | ||
- day | ||
- start_time | ||
- end_time | ||
- available | ||
|
||
|
||
#### Modelos | ||
1. Servicios monitoreados | ||
- Bloques de 1h | ||
- Horario establecido (grupo de bloques) | ||
2. Semana | ||
3. Engineer | ||
4. Turno (bloques de 1 hora) | ||
5. Asignacion (Relacion Ingeniero - Hora) | ||
|
||
#### Arquitectura Frontend (Grafica Figma) | ||
- View | ||
- Components | ||
- provider: useShiftManagement | ||
- CompanyServiceApi.ts | ||
#### Arquitectura Backend (Grafica Figma) | ||
|
||
### Ejecución | ||
#### Ambiente de desarrollo | ||
- Se ha usado Devcontainer y docker-compose para facilitar el desarrollo usando contenedores y vscode | ||
- https://code.visualstudio.com/docs/devcontainers/containers | ||
|
||
- Pasos para ejecutar: | ||
- Tener instalado la extension Devcontainer en vscode | ||
- Abrir el proyecto en vscode | ||
- Ejecutar el contenedor Rails API Container: | ||
- abrir command palette: ctrl + shift + p | ||
- Seleccionar: Reopen in container | ||
- Seleccionar: "Rails API Container" | ||
- Dentro ejecutar: `rails s` | ||
- Ejecutar el contenedor Vue Container: | ||
- abrir command palette: ctrl + shift + p | ||
- Seleccionar: Reopen in container | ||
- Seleccionar: "Vue Container" | ||
- Dentro ejecutar: `yarn dev` | ||
- navegar a 0.0.0.0:8080 para empezar a usar la app | ||
- Ejecutar tests e2e: | ||
```bash | ||
# Conectarse a contenedor de playwright | ||
docker exec -it monit-playwright /bin/bash | ||
# ejectuar tests | ||
yarn test:e2e | ||
``` | ||
|
||
|
||
#### Alternativa: | ||
- usar directamente docker-compose up desde la ruta base | ||
```bash | ||
docker-compose -f .devcontainer/docker-compose.yml up | ||
# verificar los servicios | ||
``` | ||
|
||
- navegar a 0.0.0.0:8080 para empezar a usar la app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
class CompanyServicesController < ApplicationController | ||
before_action :set_company_service, only: %i[ show update destroy ] | ||
|
||
# GET /company_services | ||
# GET /company_services.json | ||
def index | ||
@company_services = CompanyService.all | ||
end | ||
|
||
# GET /company_services/1 | ||
# GET /company_services/1.json | ||
def show | ||
end | ||
|
||
# POST /company_services | ||
# POST /company_services.json | ||
def create | ||
@company_service = CompanyService.new(company_service_params) | ||
|
||
if @company_service.save | ||
render :show, status: :created, location: @company_service | ||
else | ||
render json: @company_service.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# PATCH/PUT /company_services/1 | ||
# PATCH/PUT /company_services/1.json | ||
def update | ||
if @company_service.update(company_service_params) | ||
render :show, status: :ok, location: @company_service | ||
else | ||
render json: @company_service.errors, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
# DELETE /company_services/1 | ||
# DELETE /company_services/1.json | ||
def destroy | ||
@company_service.destroy! | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_company_service | ||
@company_service = CompanyService.find(params[:id]) | ||
end | ||
|
||
# Only allow a list of trusted parameters through. | ||
def company_service_params | ||
params.require(:company_service).permit(:name, :contract_start_date, :contract_end_date) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# == Schema Information | ||
# | ||
# Table name: company_services | ||
# | ||
# id :bigint not null, primary key | ||
# name :string | ||
# contract_start_date :datetime | ||
# contract_end_date :datetime | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
class CompanyService < ApplicationRecord | ||
end |
2 changes: 2 additions & 0 deletions
2
backend/app/views/company_services/_company_service.json.jbuilder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! company_service, :id, :name, :contract_start_date, :contract_end_date, :created_at, :updated_at | ||
json.url company_service_url(company_service, format: :json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
json.data do | ||
json.array! @company_services, partial: "company_services/company_service", as: :company_service | ||
end | ||
|
||
json.status 200 | ||
json.statusText "OK" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "company_services/company_service", company_service: @company_service |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
backend/db/migrate/20240802031906_create_company_services.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateCompanyServices < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :company_services do |t| | ||
t.string :name | ||
t.datetime :contract_start_date | ||
t.datetime :contract_end_date | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
# This file should ensure the existence of records required to run the application in every environment (production, | ||
# development, test). The code here should be idempotent so that it can be executed at any point in every environment. | ||
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup). | ||
# | ||
# Example: | ||
# | ||
# ["Action", "Comedy", "Drama", "Horror"].each do |genre_name| | ||
# MovieGenre.find_or_create_by!(name: genre_name) | ||
# end | ||
require 'faker' | ||
|
||
10.times do | ||
company_service = CompanyService.create( | ||
name: Faker::Company.unique.name, | ||
contract_start_date: Faker::Date.backward(days: 30), | ||
contract_end_date: Faker::Date.forward(days: 30) | ||
) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# == Schema Information | ||
# | ||
# Table name: company_services | ||
# | ||
# id :bigint not null, primary key | ||
# name :string | ||
# contract_start_date :datetime | ||
# contract_end_date :datetime | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# | ||
FactoryBot.define do | ||
factory :company_service do | ||
name { "MyString" } | ||
contract_start_date { "2024-08-02 03:19:06" } | ||
contract_end_date { "2024-08-02 03:19:06" } | ||
end | ||
end |
Oops, something went wrong.