From fad9a91fb4140b2d5896d8d757ae61ca7be7b8e2 Mon Sep 17 00:00:00 2001 From: Rob Dennett <rob.dennett@twdb.texas.gov> Date: Tue, 26 Nov 2024 10:12:23 -0600 Subject: [PATCH] Fixes #428 --- src/data_hub/analytics/models.py | 330 ------------------ src/data_hub/analytics/templates/hello.html | 1 - .../analytics/templates/stats-old.html | 85 ----- src/data_hub/analytics/templates/stats.html | 2 +- src/data_hub/analytics/views.py | 2 - 5 files changed, 1 insertion(+), 419 deletions(-) delete mode 100644 src/data_hub/analytics/models.py delete mode 100644 src/data_hub/analytics/templates/hello.html delete mode 100644 src/data_hub/analytics/templates/stats-old.html diff --git a/src/data_hub/analytics/models.py b/src/data_hub/analytics/models.py deleted file mode 100644 index 8545a4af..00000000 --- a/src/data_hub/analytics/models.py +++ /dev/null @@ -1,330 +0,0 @@ -from django.db import models - -# Create your models here. -class DownloadLog2021(models.Model): - class Meta: - managed = False - db_table = "download_log_2021" - verbose_name = 'Download log 2021 entry' - verbose_name_plural = 'Download logs 2021' - - id = models.UUIDField( - 'ID', - primary_key=True - ) - - date = models.DateField( - "Date" - ) - - time = models.TimeField( - "Time without timezone" - ) - - x_edge_result_type = models.CharField( - "X Edge Result Type" - ) - - x_edge_detailed_result_type = models.TextField( - "X Edge Detailed Result Type" - ) - - x_host_header = models.CharField( - "X Host Header" - ) - - cs_uri_stem = models.TextField( - "CS URI Stem" - ) - - collection_id = models.CharField( - "Collection ID" - ) - - collection_shortname = models.CharField( - "Collection Short Name" - ) - - area_type_id = models.CharField( - "Area Type ID" - ) - - file_type = models.CharField( - "File Type" - ) - - hist_band = models.CharField( - "Hist Band" - ) - - hist_collective = models.CharField( - "Hist Collective" - ) - - hist_mission = models.CharField( - "Hist Mission" - ) - - hist_type = models.CharField( - "Hist Type" - ) - - hist_product = models.CharField( - "Hist Product" - ) - - hist_file = models.CharField( - "Hist File" - ) - - def __str__(self): - return str(self.id) - - def getYear(): - return 2021 - -class DownloadLog2022(models.Model): - class Meta: - managed = False - db_table = "download_log_2022" - verbose_name = 'Download log 2022 entry' - verbose_name_plural = 'Download logs 2022' - - id = models.UUIDField( - 'ID', - primary_key=True - ) - - date = models.DateField( - "Date" - ) - - time = models.TimeField( - "Time without timezone" - ) - - x_edge_result_type = models.CharField( - "X Edge Result Type" - ) - - x_edge_detailed_result_type = models.TextField( - "X Edge Detailed Result Type" - ) - - x_host_header = models.CharField( - "X Host Header" - ) - - cs_uri_stem = models.TextField( - "CS URI Stem" - ) - - collection_id = models.CharField( - "Collection ID" - ) - - collection_shortname = models.CharField( - "Collection Short Name" - ) - - area_type_id = models.CharField( - "Area Type ID" - ) - - file_type = models.CharField( - "File Type" - ) - - hist_band = models.CharField( - "Hist Band" - ) - - hist_collective = models.CharField( - "Hist Collective" - ) - - hist_mission = models.CharField( - "Hist Mission" - ) - - hist_type = models.CharField( - "Hist Type" - ) - - hist_product = models.CharField( - "Hist Product" - ) - - hist_file = models.CharField( - "Hist File" - ) - - def __str__(self): - return str(self.id) - - def getYear(): - return 2022 - -class DownloadLog2023(models.Model): - class Meta: - managed = False - db_table = "download_log_2023" - verbose_name = 'Download log 2023 entry' - verbose_name_plural = 'Download logs 2023' - - id = models.UUIDField( - 'ID', - primary_key=True - ) - - date = models.DateField( - "Date" - ) - - time = models.TimeField( - "Time without timezone" - ) - - x_edge_result_type = models.CharField( - "X Edge Result Type" - ) - - x_edge_detailed_result_type = models.TextField( - "X Edge Detailed Result Type" - ) - - x_host_header = models.CharField( - "X Host Header" - ) - - cs_uri_stem = models.TextField( - "CS URI Stem" - ) - - collection_id = models.CharField( - "Collection ID" - ) - - collection_shortname = models.CharField( - "Collection Short Name" - ) - - area_type_id = models.CharField( - "Area Type ID" - ) - - file_type = models.CharField( - "File Type" - ) - - hist_band = models.CharField( - "Hist Band" - ) - - hist_collective = models.CharField( - "Hist Collective" - ) - - hist_mission = models.CharField( - "Hist Mission" - ) - - hist_type = models.CharField( - "Hist Type" - ) - - hist_product = models.CharField( - "Hist Product" - ) - - hist_file = models.CharField( - "Hist File" - ) - - def __str__(self): - return str(self.id) - - def getYear(): - return 2023 - -class DownloadLog2024(models.Model): - class Meta: - managed = False - db_table = "download_log_2024" - verbose_name = 'Download log 2024 entry' - verbose_name_plural = 'Download logs 2024' - - id = models.UUIDField( - 'ID', - primary_key=True - ) - - date = models.DateField( - "Date" - ) - - time = models.TimeField( - "Time without timezone" - ) - - x_edge_result_type = models.CharField( - "X Edge Result Type" - ) - - x_edge_detailed_result_type = models.TextField( - "X Edge Detailed Result Type" - ) - - x_host_header = models.CharField( - "X Host Header" - ) - - cs_uri_stem = models.TextField( - "CS URI Stem" - ) - - collection_id = models.CharField( - "Collection ID" - ) - - collection_shortname = models.CharField( - "Collection Short Name" - ) - - area_type_id = models.CharField( - "Area Type ID" - ) - - file_type = models.CharField( - "File Type" - ) - - hist_band = models.CharField( - "Hist Band" - ) - - hist_collective = models.CharField( - "Hist Collective" - ) - - hist_mission = models.CharField( - "Hist Mission" - ) - - hist_type = models.CharField( - "Hist Type" - ) - - hist_product = models.CharField( - "Hist Product" - ) - - hist_file = models.CharField( - "Hist File" - ) - - def __str__(self): - return str(self.id) - - def getYear(): - return 2024 \ No newline at end of file diff --git a/src/data_hub/analytics/templates/hello.html b/src/data_hub/analytics/templates/hello.html deleted file mode 100644 index 973e574f..00000000 --- a/src/data_hub/analytics/templates/hello.html +++ /dev/null @@ -1 +0,0 @@ -<h1>{{ reply }}</h1> diff --git a/src/data_hub/analytics/templates/stats-old.html b/src/data_hub/analytics/templates/stats-old.html deleted file mode 100644 index e59a1161..00000000 --- a/src/data_hub/analytics/templates/stats-old.html +++ /dev/null @@ -1,85 +0,0 @@ -<script src="https://cdn.jsdelivr.net/npm/chart.js@4.2.1/dist/chart.umd.min.js"></script> - -<canvas id="chart" width="500" height="500"></canvas> - -<script> - const ctx = document.getElementById("chart"); - - new Chart(ctx, { - type: "bar", - data: { - labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"], - datasets: [ - { - label: "# of Votes", - data: [12, 19, 3, 5, 2, 3], - borderWidth: 1, - }, - ], - }, - options: { - scales: { - y: { - beginAtZero: true, - }, - }, - }, - }); -</script> - -<p>Total Downloads</p> -<p>{{total_downloads}}</p> -<p>Successful Data Downloads</p> -<p>{{total_success_data}}</p> -<p>Successful Map Downloads</p> -<p>{{total_success_map}}</p> -<p>-----------------------</p> -<p>top 10 successfully downloaded files</p> -{% for item in top_files %} -<p>{{item.0}} {{item.1}}</p> -{% endfor %} -<p>-----------------------</p> -<p> - top 10 successfully downloaded data collections (historic imagery included) -</p> -{% for item in top_cbc %} -<p>{{item.0}} {{item.1}}</p> -{% endfor %} -<p>-----------------------</p> -<p>top 10 successfully downloaded historic imagery data collections</p> -{% for item in top_cbh %} -<p>{{item.0}} {{item.1}}</p> -{% endfor %} -<p>-----------------------</p> -<p>top 10 successfully downloaded maps</p> -{% for item in top_cbm %} -<p>{{item.0}} {{item.1}}</p> -{% endfor %} -<p>-----------------------</p> -<p>total successfully downloaded count by resource_type</p> -{% for item in top_cbrt %} -<p>{{item.0}} {{item.1}}</p> -{% endfor %} -<p>-----------------------</p> -<p> - {{no_downloads_num}} of {{total_downloadable}} downloadable collections had - zero download attempts (historic imagery NOT included) -</p> -{% for item in no_downloads %} -<p>{{item}}</p> -{% endfor %} -<form action="/analytics/get_monthly_stats/" method="GET"> - <p> - Start date - <input - type="date" - name="start_date" - value="{{ request.GET.start_date }}" - /> - </p> - <p> - End date - <input type="date" name="end_date" value="{{ request.GET.end_date }}" /> - </p> - <p><input type="submit" value="Submit" /></p> -</form> diff --git a/src/data_hub/analytics/templates/stats.html b/src/data_hub/analytics/templates/stats.html index a8318955..fa019d00 100644 --- a/src/data_hub/analytics/templates/stats.html +++ b/src/data_hub/analytics/templates/stats.html @@ -299,7 +299,7 @@ #service-types { background-color: white; - width: 600px; + width: 100%; max-height: 365px; overflow-y: auto; order: 2; diff --git a/src/data_hub/analytics/views.py b/src/data_hub/analytics/views.py index 8bf169e5..ddfc2b35 100644 --- a/src/data_hub/analytics/views.py +++ b/src/data_hub/analytics/views.py @@ -3,9 +3,7 @@ from django.contrib.auth.decorators import login_required from lcd.models import Collection, TemplateType from msd.models import MapCollection -from analytics.models import DownloadLog2024 import inspect -import analytics.models import os from datetime import datetime import time