Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
88be4a1
agregando configuracion de integracion con github y sonarcloud
nelsonortfan Nov 2, 2024
b1097fb
agregando linea de exclusion de test
nelsonortfan Nov 2, 2024
5a8672c
linea de ejemplo de print
nelsonortfan Nov 2, 2024
6fd918a
limpiando archivos de cobertura
nelsonortfan Nov 2, 2024
d0e342f
Algunos cambios y deshabilitar SCM en SonarCloud
nelsonortfan Nov 2, 2024
a04e0b5
modificando flujo
nelsonortfan Nov 2, 2024
d5a29d9
removiendo linea de ejemplo
nelsonortfan Nov 2, 2024
996ff81
comando directo sobre pruebas
nelsonortfan Nov 2, 2024
8a030e4
prueba desde archivo
nelsonortfan Nov 2, 2024
7f7eeb2
cambios archivo properties2
nelsonortfan Nov 2, 2024
48d398c
cambio orden de propiedades
nelsonortfan Nov 2, 2024
e3f6ee2
agregando otro folder
nelsonortfan Nov 2, 2024
f9185ea
agregando python v3.7
nelsonortfan Nov 2, 2024
3d3346c
agregando linea de prueba para validar nuevo perfil
nelsonortfan Nov 2, 2024
64588ab
removiendo valor de K para eliminar bug en archivo index.html
nelsonortfan Nov 3, 2024
d54b2d1
removiendo issue de bug de alt en img archivo index.html
nelsonortfan Nov 3, 2024
39e0535
Corrigiendo complejidad ciclomatica smell code
nelsonortfan Nov 3, 2024
ec0f9db
eliminando nuevo issue para evitar fuga de agua en index.html
nelsonortfan Nov 3, 2024
4d67505
Merge pull request #2 from nelsonortfan/fix_Nelson
Adrestes7 Nov 3, 2024
6515305
Agregando var a la variable changes_plot code smell
nelsonortfan Nov 3, 2024
f64b0d0
Cambiando mensaje repetido a constante para remediar code smell
nelsonortfan Nov 3, 2024
b459379
agregando una excepcion generica para atrapar cualquier error en code…
nelsonortfan Nov 3, 2024
bb21f22
removiendo variable e para evitar fuga de agua en code smell de excep…
nelsonortfan Nov 3, 2024
0662177
Merge pull request #4 from nelsonortfan/fix_Nelson
Adrestes7 Nov 3, 2024
82c81b5
Arreglar deuda tecnica
Nov 3, 2024
687c82b
Cambiar el nombre de la variable para evitar añadir nuevo code smell
Nov 3, 2024
8fac391
Se añade excepción personalizada
Nov 3, 2024
a2366df
Merge pull request #5 from nelsonortfan/technical-debt-1-andres
nelsonortfan Nov 3, 2024
cccfc9b
Merge pull request #6 from nelsonortfan/technical-debt-2-andres
nelsonortfan Nov 3, 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
28 changes: 0 additions & 28 deletions .coveragerc

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build
on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]
jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: Verificar version de Python
run: |
python --version
- name: Instalación de librerías y dependencias
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: pruebas+coverage
id: pruebas
run: |
pwd
ls
python -m coverage run -m unittest discover -s tests -v
echo 'Miramos el reporte'
coverage report
echo 'Guardamos archivo'
python -m coverage xml -i
- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
28 changes: 0 additions & 28 deletions .github/workflows/test.yml

This file was deleted.

Binary file added __pycache__/setup.cpython-310.pyc
Binary file not shown.
Binary file added aplicacion.sqlite
Binary file not shown.
18 changes: 9 additions & 9 deletions reports/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,19 @@

var positions = styleCache[key].positions;

for (var i = 0, position; position = positions[i]; i++) {
var i = 0; // Initialize i outside the loop
while (i < positions.length) {
var position = positions[i];

if (position.active) {
if (!position.rendered) {
layer.append(position.element);
position.rendered = true;
}
i++; // Increment i only when the position is active
} else {
positions.splice(i--, 1);
if (position.rendered) {
position.element.detach();
}
positions.splice(i, 1); // Remove the inactive position
// No need to increment i here, as splice shifts the elements
}
}

Expand Down Expand Up @@ -1222,8 +1224,6 @@
// middle point has same y
points[k + 1] = points[k - ps + 1];

// we've added a point, better reflect that
k += ps;
}
}
}
Expand Down Expand Up @@ -4417,9 +4417,9 @@
<p>Statistical information for the repository 'MISW-4101-Practicas-TutorialCancionesTags' was gathered on 2021/02/16.<br>The output has been generated by <a href="https://github.com/ejwa/gitinspector">gitinspector</a> 0.5.0dev. The statistical analysis tool for git repositories.</p>
</div></div>

<div><div class="box"><p>The following historical commit information, by author, was found.</p><div><table id="changes" class="git"><thead><tr> <th>Author</th> <th>Commits</th> <th>Insertions</th> <th>Deletions</th> <th>% of changes</th></tr></thead><tbody><tr ><td><img src="https://www.gravatar.com/avatar/a2516bd03c82602d5c6e73218532fc37?default=identicon&size=20"/>avargas20</td><td>33</td><td>2514</td><td>124</td><td>100.00</td></tr><tfoot><tr> <td colspan="5">&nbsp;</td> </tr></tfoot></tbody></table><div class="chart" id="changes_chart"></div></div><script type="text/javascript"> changes_plot = $.plot($("#changes_chart"), [{label: "avargas20", data: 100.00}], { series: { pie: { innerRadius: 0.4, show: true, combine: { threshold: 0.01, label: "Minor Authors" } } }, grid: { hoverable: true } });</script></div></div>
<div><div class="box"><p>The following historical commit information, by author, was found.</p><div><table id="changes" class="git"><thead><tr> <th>Author</th> <th>Commits</th> <th>Insertions</th> <th>Deletions</th> <th>% of changes</th></tr></thead><tbody><tr ><td><img src="https://www.gravatar.com/avatar/a2516bd03c82602d5c6e73218532fc37?default=identicon&size=20"/>avargas20</td><td>33</td><td>2514</td><td>124</td><td>100.00</td></tr><tfoot><tr> <td colspan="5">&nbsp;</td> </tr></tfoot></tbody></table><div class="chart" id="changes_chart"></div></div><script type="text/javascript"> var changes_plot = $.plot($("#changes_chart"), [{label: "avargas20", data: 100.00}], { series: { pie: { innerRadius: 0.4, show: true, combine: { threshold: 0.01, label: "Minor Authors" } } }, grid: { hoverable: true } });</script></div></div>
<div><div id="timeline" class="box"><p>The following history timeline has been gathered from the repository. (Green = Additions , Red = Deletions)</p>
<table class="git full"><thead><tr><th>Author</th><th>08/02 - 14/02</th></tr></thead><tbody><tr><td><img src="https://www.gravatar.com/avatar/a2516bd03c82602d5c6e73218532fc37?default=identicon&size=20"/>avargas20</td><td><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div></td></tr><tfoot><tr><td><strong>Modified Rows:</strong></td><td>2638</td></tr></tfoot></tbody></table>
<table class="git full"><thead><tr><th>Author</th><th>08/02 - 14/02</th></tr></thead><tbody><tr><td><img src="https://www.gravatar.com/avatar/a2516bd03c82602d5c6e73218532fc37?default=identicon&size=20" alt="figura color naranja como un sol" />avargas20</td><td><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div><div class="insert">&nbsp;</div></td></tr><tfoot><tr><td><strong>Modified Rows:</strong></td><td>2638</td></tr></tfoot></tbody></table>
</div></div>
<div><div id="archivosxusuarios" class="box"><p>The following file participation percentage table, by author, was calculated.</p>
<table class="git full" border=1 frame=void rules=rows><thead><tr><th>File</th> <th>Author</th> <th>Percentage</th></tr></thead><tbody><tr><td rowspan="+1+">docs/conf.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/__main__.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">setup.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/modelo/album.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">src/modelo/cancion.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/logica/coleccion.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">src/modelo/interprete.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/modelo/declarative_base.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">src/vista/interfaz_coleccion.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/vista/vista_album.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">src/vista/vista_busqueda.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/vista/vista_cancion.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">tests/test_album.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">src/vista/vista_lista_cancion.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">src/vista/vista_lista_album.py</td><td> avargas20</td><td>100.0%</td></tr><tr class="odd"><td rowspan="+1+">tests/test_cancion.py</td><td> avargas20</td><td>100.0%</td></tr><tr><td rowspan="+1+">tests/test_interprete.py</td><td> avargas20</td><td>100.0%</td></tr></tbody></table>
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
coverage==5.4
Faker==5.8.0
PyQt5==5.15.2
#PyQt5==5.15.2
SQLAlchemy==1.3.22
16 changes: 16 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
sonar.projectKey=nelsonortfan_TutorialCancionesTags
sonar.organization=nelsonortfan

sonar.coverage.exclusions=**tests/**,**src/vista/**,**src/recursos/**,**docs/**,**setup.py**
sonar.python.coverage.reportPaths=coverage.xml
# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=TutorialCancionesTags
#sonar.projectVersion=1.0


# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
# This is a comment
82 changes: 47 additions & 35 deletions src/logica/coleccion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from src.modelo.cancion import Cancion
from src.modelo.declarative_base import engine, Base, session
from src.modelo.interprete import Interprete
from sqlalchemy.exc import SQLAlchemyError


class Coleccion():
Expand Down Expand Up @@ -41,7 +42,10 @@ def eliminar_album(self, album_id):
session.delete(album)
session.commit()
return True
except:
except SQLAlchemyError as e:
session.rollback() # Roll back the session in case of error
# Optionally, log the exception or handle it further
print(f"Error occurred while deleting canción: {e}") # Replace with appropriate logging
return False

def dar_albumes(self):
Expand All @@ -67,39 +71,41 @@ def buscar_albumes_por_titulo(self, album_titulo):
return albumes

def agregar_cancion(self, titulo, minutos, segundos, compositor, album_id, interpretes):
interpretesCancion = []
if len(interpretes) == 0:
if not interpretes: # Check if interpretes is empty
return False
else:
if album_id > 0:
busqueda = session.query(Cancion).filter(Cancion.albumes.any(Album.id.in_([album_id])),
Cancion.titulo == titulo).all()
if len(busqueda) == 0:
album = session.query(Album).filter(Album.id == album_id).first()
nuevaCancion = Cancion(titulo=titulo, minutos=minutos, segundos=segundos, compositor=compositor,
albumes=[album])
for item in interpretes:
interprete = Interprete(nombre=item["nombre"], texto_curiosidades=item["texto_curiosidades"],
cancion=nuevaCancion.id)
session.add(interprete)
interpretesCancion.append(interprete)
nuevaCancion.interpretes = interpretesCancion
session.add(nuevaCancion)
session.commit()
return True
else:
return False
else:
nuevaCancion = Cancion(titulo=titulo, minutos=minutos, segundos=segundos, compositor=compositor)
for item in interpretes:
interprete = Interprete(nombre=item["nombre"], texto_curiosidades=item["texto_curiosidades"],
cancion=nuevaCancion.id)
session.add(interprete)
interpretesCancion.append(interprete)
nuevaCancion.interpretes = interpretesCancion
session.add(nuevaCancion)
session.commit()
return True

# Function to create a new Cancion
def create_cancion(album=None):
nuevaCancion = Cancion(titulo=titulo, minutos=minutos, segundos=segundos, compositor=compositor,
albumes=[album] if album else [])
interpretes = [] # Initialize interpretesCancion list

for item in interpretes:
interprete = Interprete(nombre=item["nombre"], texto_curiosidades=item["texto_curiosidades"],
cancion=nuevaCancion.id)
session.add(interprete)
interpretes.append(interprete)

nuevaCancion.interpretes = interpretes
session.add(nuevaCancion)
session.commit()
return True

# If an album ID is provided, check for existing songs
if album_id > 0:
busqueda = session.query(Cancion).filter(
Cancion.albumes.any(Album.id.in_([album_id])),
Cancion.titulo == titulo
).all()

if busqueda: # If the song already exists
return False

album = session.query(Album).filter(Album.id == album_id).first()
return create_cancion(album) # Create song with album

# Create song without an album
return create_cancion()

def editar_cancion(self, cancion_id, titulo, minutos, segundos, compositor, interpretes):
busqueda = session.query(Cancion).filter(Cancion.titulo == titulo, Cancion.id != cancion_id).all()
Expand Down Expand Up @@ -131,7 +137,10 @@ def eliminar_cancion(self, cancion_id):
return True
else:
return False
except:
except SQLAlchemyError as e:
session.rollback() # Roll back the session in case of error
# Optionally, log the exception or handle it further
print(f"Error occurred while deleting canción: {e}") # Replace with appropriate logging
return False

def dar_canciones(self):
Expand Down Expand Up @@ -203,7 +212,10 @@ def eliminar_interprete(self, interprete_id):
session.delete(interprete)
session.commit()
return True
except:
except SQLAlchemyError as e:
session.rollback() # Roll back the session in case of error
# Optionally, log the exception or handle it further
print(f"Error occurred while deleting canción: {e}") # Replace with appropriate logging
return False

def dar_interpretes(self):
Expand Down
16 changes: 10 additions & 6 deletions src/vista/interfaz_coleccion.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ class App(QApplication):
Clase principal de la interfaz
'''

MENSAJE_ERROR = "Error al buscar álbum"

MENSAJE_ERROR_CANCION = "Error al guardar canción"

def __init__(self, sys_argv, logica):
'''
Constructor de la interfaz
Expand Down Expand Up @@ -155,15 +159,15 @@ def crear_cancion(self, nueva_cancion, interpretes, id_album=-1):
if nueva_cancion["titulo"] == "" or nueva_cancion["minutos"] == "" or nueva_cancion["segundos"] == "":
mensaje_error = QMessageBox()
mensaje_error.setIcon(QMessageBox.Critical)
mensaje_error.setWindowTitle("Error al guardar canción")
mensaje_error.setWindowTitle(self.MENSAJE_ERROR_CANCION)
mensaje_error.setText("Ningún campo debe estar vacio")
mensaje_error.setStandardButtons(QMessageBox.Ok)
mensaje_error.exec_()
else:
if int(nueva_cancion["minutos"]) == 0 and int(nueva_cancion["segundos"]) < 10:
mensaje_error = QMessageBox()
mensaje_error.setIcon(QMessageBox.Critical)
mensaje_error.setWindowTitle("Error al guardar canción")
mensaje_error.setWindowTitle(self.MENSAJE_ERROR_CANCION)
mensaje_error.setText("La duración de la canción debe ser mínimo de 10 sg")
mensaje_error.setStandardButtons(QMessageBox.Ok)
mensaje_error.exec_()
Expand All @@ -177,7 +181,7 @@ def crear_cancion(self, nueva_cancion, interpretes, id_album=-1):
if operacion is False:
mensaje_error = QMessageBox()
mensaje_error.setIcon(QMessageBox.Critical)
mensaje_error.setWindowTitle("Error al guardar canción")
mensaje_error.setWindowTitle(self.MENSAJE_ERROR_CANCION)
mensaje_error.setText("Ya existe una canción con el título " + nueva_cancion["titulo"] + " en el álbum")
mensaje_error.setStandardButtons(QMessageBox.Ok)
mensaje_error.exec_()
Expand All @@ -190,7 +194,7 @@ def mostrar_resultados_albumes(self, nombre_album):
if len(albumes) == 0:
mensaje_error = QMessageBox()
mensaje_error.setIcon(QMessageBox.Critical)
mensaje_error.setWindowTitle("Error al buscar álbum")
mensaje_error.setWindowTitle(self.MENSAJE_ERROR)
mensaje_error.setText("No hay álbumes con el título " + nombre_album)
mensaje_error.setStandardButtons(QMessageBox.Ok)
mensaje_error.exec_()
Expand All @@ -204,7 +208,7 @@ def mostrar_resultados_canciones(self, nombre_cancion):
if len(canciones) == 0:
mensaje_error = QMessageBox()
mensaje_error.setIcon(QMessageBox.Critical)
mensaje_error.setWindowTitle("Error al buscar álbum")
mensaje_error.setWindowTitle(self.MENSAJE_ERROR)
mensaje_error.setText("No hay canciones con el título " + nombre_cancion)
mensaje_error.setStandardButtons(QMessageBox.Ok)
mensaje_error.exec_()
Expand All @@ -218,7 +222,7 @@ def mostrar_resultados_interpretes(self, nombre_interprete):
if len(interpretes) == 0:
mensaje_error = QMessageBox()
mensaje_error.setIcon(QMessageBox.Critical)
mensaje_error.setWindowTitle("Error al buscar álbum")
mensaje_error.setWindowTitle(self.MENSAJE_ERROR)
mensaje_error.setText("No hay canciones con el interprete " + nombre_interprete)
mensaje_error.setStandardButtons(QMessageBox.Ok)
mensaje_error.exec_()
Expand Down
Loading