diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000..76307af5 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,33 @@ +name: Build +on: + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] +jobs: + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: '3.7' + - name: Instalación de librerías y dependencias + run: | + python -m pip install --upgrade pip + python -m pip install pytest + - name: pruebas+coverage + run: | + pytest + exit 5 + continue-on-error: true + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} \ No newline at end of file diff --git a/.project b/.project new file mode 100644 index 00000000..16de2b53 --- /dev/null +++ b/.project @@ -0,0 +1,11 @@ + + + IOTMonitoringServer + + + + + + + + diff --git a/IOTMonitoringServer/settings.py b/IOTMonitoringServer/settings.py index 114ccc2f..20a5f8dc 100644 --- a/IOTMonitoringServer/settings.py +++ b/IOTMonitoringServer/settings.py @@ -27,7 +27,7 @@ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True -ALLOWED_HOSTS = ["localhost", "ip.maquina.visualizador"] +ALLOWED_HOSTS = ["localhost", "3.237.205.218"] # Application definition @@ -96,7 +96,7 @@ "NAME": "iot_data", # Nombre de la base de datos "USER": "dbadmin", # Nombre de usuario "PASSWORD": "uniandesIOT1234*", # Contraseña - "HOST": "ip.maquina.db", # Dirección IP de la base de datos + "HOST": "44.213.121.117", # Dirección IP de la base de datos "PORT": "", # Puerto de la base de datos } } @@ -156,7 +156,7 @@ CRISPY_TEMPLATE_PACK = 'bootstrap4' # Dirección del bróker MQTT -MQTT_HOST = "ip.maquina.mqtt" +MQTT_HOST = "18.205.3.25" # Puerto del bróker MQTT MQTT_PORT = 8082 diff --git a/IOTMonitoringServer/static/css/mystyle.css b/IOTMonitoringServer/static/css/mystyle.css index 7ee232f3..143c64c2 100644 --- a/IOTMonitoringServer/static/css/mystyle.css +++ b/IOTMonitoringServer/static/css/mystyle.css @@ -1,7 +1,3 @@ -.table-bordered { - border: 0 !important; -} - .table-bordered > thead > tr > th { border: 0 !important; border-bottom: solid 1px #343a40 !important; @@ -11,11 +7,6 @@ table.table-bordered.dataTable tbody td { border-bottom-width: 1px !important; } -.table-bordered > tbody > tr > td { - border: 0 !important; - border-bottom: 1px solid #cccccc !important; -} - .table-md th, .table-md td { padding: 0.55rem; font-size: 14px; diff --git a/control/monitor.py b/control/monitor.py index 43d7af0c..a7411fff 100644 --- a/control/monitor.py +++ b/control/monitor.py @@ -12,10 +12,7 @@ def analyze_data(): - # Consulta todos los datos de la última hora, los agrupa por estación y variable - # Compara el promedio con los valores límite que están en la base de datos para esa variable. - # Si el promedio se excede de los límites, se envia un mensaje de alerta. - + print("Calculando alertas...") data = Data.objects.filter( diff --git a/receiver/models.py b/receiver/models.py index 8becaf00..b3ae3a6f 100644 --- a/receiver/models.py +++ b/receiver/models.py @@ -10,28 +10,24 @@ class City(models.Model): name = models.CharField(max_length=50, unique=True, blank=False) - code = models.CharField(max_length=50, null=True) + code = models.CharField(max_length=50, blank=True) def str(self): return "{}".format(self.name) - class State(models.Model): name = models.CharField(max_length=50, unique=False, blank=False) - code = models.CharField(max_length=50, null=True) + code = models.CharField(max_length=50, blank=True) def str(self): return "{}".format(self.name) - class Country(models.Model): name = models.CharField(max_length=50, unique=False, blank=False) - code = models.CharField(max_length=50, null=True) + code = models.CharField(max_length=50, blank=True) def str(self): return "{}".format(self.name) - - class Location(models.Model): description = models.CharField(max_length=200, blank=True) lat = models.DecimalField( @@ -42,14 +38,12 @@ class Location(models.Model): state = models.ForeignKey(State, on_delete=models.CASCADE) country = models.ForeignKey(Country, on_delete=models.CASCADE) active = models.BooleanField(default=True) - class Meta: unique_together = ("city", "state", "country") def str(self): return "{} {} {}".format(self.city.name, self.state.name, self.country.name) - class Measurement(models.Model): name = models.CharField(max_length=50, blank=False) unit = models.CharField(max_length=50, blank=False) diff --git a/requeriments.py b/requeriments.txt similarity index 100% rename from requeriments.py rename to requeriments.txt diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..11c60df2 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,14 @@ +sonar.projectKey=alexyirsa_IOTMonitoringServer +sonar.organization=alexyirsa +sonar.coverage.exclusions=**tests/**,**src/vista/**,**docs/**,**setup.py** + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=IOTMonitoringServer +#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 \ No newline at end of file