diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml
new file mode 100644
index 0000000..a233caf
--- /dev/null
+++ b/.github/workflows/deploy.yml
@@ -0,0 +1,34 @@
+name: Deploy Studio Maker in Azure
+
+# Dispara o workflow para push e pull request na branch 'dev'
+on:
+ push:
+ branches:
+ - dev
+
+
+
+
+jobs:
+ run-script:
+ runs-on: ubuntu-latest
+
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v2
+
+ - name: executing remote ssh commands using password
+ uses: appleboy/ssh-action@v1.0.3
+ with:
+ host: ${{ secrets.IP_VM_AZURE_DEV }}
+ username: ${{ secrets.USER_VM_AZURE_DEV }}
+ password: ${{ secrets.USER_VM_AZURE_DEV }}
+ port: 22
+ request_pty: true
+ script: |
+ ls -alt
+ cd /home/Calculus-admin1/app
+ pwd
+ sudo ./manage_process_back_studio.sh
+ echo "Starting deploy Studio Service"
+ sudo ./deploy_back_studio.sh
\ No newline at end of file
diff --git a/reports/sonar-report.xml b/reports/sonar-report.xml
new file mode 100644
index 0000000..7b51968
--- /dev/null
+++ b/reports/sonar-report.xml
@@ -0,0 +1,72 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/scripts/deploy_back_studio.sh b/scripts/deploy_back_studio.sh
new file mode 100644
index 0000000..7641aad
--- /dev/null
+++ b/scripts/deploy_back_studio.sh
@@ -0,0 +1,62 @@
+#!/bin/bash
+
+SESSION_NAME="backend-user-session"
+ENV="dev"
+DIR1="/home/Calculus-admin1/app/2024.1-CALCULUS-StudioMaker"
+
+# Comandos renomeados para refletir a ordem de execução
+CMD1="git fetch"
+CMD2="git checkout $ENV"
+CMD3="git pull origin $ENV"
+CMD4="npm install"
+CMD5="npm run start"
+CMD6="echo Starting Deploy Studio Maker backend"
+
+# Função para iniciar a sessão tmux e executar comandos
+start_tmux_session() {
+ # Criar uma nova sessão tmux
+ tmux kill-session -t $SESSION_NAME 2>/dev/null
+ tmux new-session -d -s $SESSION_NAME
+
+ # Executar os comandos na pasta do frontend
+ tmux send-keys -t $SESSION_NAME "cd $DIR1" C-m
+ tmux send-keys -t $SESSION_NAME "$CMD1" C-m
+ tmux send-keys -t $SESSION_NAME "$CMD2" C-m
+ tmux send-keys -t $SESSION_NAME "$CMD3" C-m
+ tmux send-keys -t $SESSION_NAME "$CMD4" C-m
+ tmux send-keys -t $SESSION_NAME "$CMD5" C-m
+ tmux send-keys -t $SESSION_NAME "$CMD6" C-m
+
+ # Anexar à sessão tmux para visualizar os comandos em execução
+# tmux attach-session -t $SESSION_NAME
+}
+
+# Função para executar o health check
+run_healthcheck() {
+ PORT=3002
+ CHECK_INTERVAL=5
+
+ echo "Deploy backend iniciado"
+ echo "Iniciando health check para a porta $PORT..."
+
+ while true; do
+ # Executa o comando para verificar se a porta está em uso
+ OUTPUT=$(ss -tuln | grep ":$PORT")
+
+ # Verifica se há algum resultado
+ if [ -n "$OUTPUT" ]; then
+ echo "A porta $PORT está em uso. Encerrando o health check."
+ echo "Deploy realizado com sucesso!"
+ break
+ else
+ echo "A porta $PORT não está em uso. Verificando novamente em $CHECK_INTERVAL segundos..."
+ sleep $CHECK_INTERVAL
+ fi
+ done
+}
+
+# Iniciar a sessão tmux e executar os comandos
+start_tmux_session
+
+# Após a execução do tmux, iniciar o health check
+run_healthcheck
diff --git a/scripts/manage_process_studio.sh b/scripts/manage_process_studio.sh
new file mode 100644
index 0000000..2578185
--- /dev/null
+++ b/scripts/manage_process_studio.sh
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+# Portas que precisam ser verificadas
+PORT1=3002
+
+# Função para encerrar processos que estão usando a porta
+kill_process_on_port() {
+ local PORT=$1
+ PID=$(lsof -t -i:$PORT)
+ if [ -n "$PID" ]; then
+ echo "Terminating process on port $PORT (PID: $PID)"
+ sudo kill -9 $PID
+ else
+ echo "No process running on port $PORT"
+ fi
+}
+
+
+# Encerrar processos nas portas especificadas
+kill_process_on_port $PORT1
+
+# Encerrar processos relacionados ao `nest`
+echo "Terminating all processes for 'nest'"
+#sudo pkill nest
diff --git a/src/journey/journey.service.ts b/src/journey/journey.service.ts
index ca26a4a..71949e9 100644
--- a/src/journey/journey.service.ts
+++ b/src/journey/journey.service.ts
@@ -110,6 +110,7 @@ export class JourneyService {
if (!journey) {
throw new NotFoundException(`Journey with ID ${id} not found`);
}
+ this.logger.log(`Deleted journey with ID ${id}`);
return journey;
}
diff --git a/src/trail/trail.controller.ts b/src/trail/trail.controller.ts
index 860d142..8da419a 100644
--- a/src/trail/trail.controller.ts
+++ b/src/trail/trail.controller.ts
@@ -35,6 +35,11 @@ export class TrailController {
return this.trailService.findAllTrails();
}
+ @Get('journey/:id')
+ async getTrailsByJourneyId(@Param('id') id: string) {
+ return this.trailService.findTrailsByJourneyId(id);
+ }
+
@Put(':id')
async updateTrail(
@Param('id') id: string,
diff --git a/src/trail/trail.service.ts b/src/trail/trail.service.ts
index d5f2fb2..9953146 100644
--- a/src/trail/trail.service.ts
+++ b/src/trail/trail.service.ts
@@ -77,6 +77,13 @@ export class TrailService {
return this.trailModel.find().exec();
}
+ async findTrailsByJourneyId(journeyId: string): Promise {
+ const journey = await this.journeyModel.findById(journeyId).exec();
+ if (!journey) {
+ throw new NotFoundException(`Journey with ID ${journeyId} not found`);
+ }
+ return await this.trailModel.find({ journey: journeyId }).exec();
+ }
async updateTrail(id: string, updateData: Partial): Promise {
const trail = await this.trailModel
.findByIdAndUpdate(id, updateData, { new: true })