From 261bd38b187e5b9577fd73a9b5593bae21491c72 Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Fri, 22 Nov 2024 16:16:39 +0100
Subject: [PATCH 1/2] [QSOs] Added QSOs per month
---
application/controllers/Dayswithqso.php | 10 +++++
application/models/Dayswithqso_model.php | 27 ++++++++++++
application/views/dayswithqso/index.php | 9 ++++
assets/js/sections/dayswithqso.js | 55 ++++++++++++++++++++++++
4 files changed, 101 insertions(+)
diff --git a/application/controllers/Dayswithqso.php b/application/controllers/Dayswithqso.php
index 5d3262cc0..f280632f4 100644
--- a/application/controllers/Dayswithqso.php
+++ b/application/controllers/Dayswithqso.php
@@ -48,4 +48,14 @@ class Dayswithqso extends CI_Controller {
echo json_encode($data);
}
+ public function get_months() {
+ //load model
+ $this->load->model('dayswithqso_model');
+
+ // get data
+ $data = $this->dayswithqso_model->getMonthsOfYear();
+ header('Content-Type: application/json');
+ echo json_encode($data);
+ }
+
}
diff --git a/application/models/Dayswithqso_model.php b/application/models/Dayswithqso_model.php
index 2a895d4a6..452ec7c77 100644
--- a/application/models/Dayswithqso_model.php
+++ b/application/models/Dayswithqso_model.php
@@ -200,4 +200,31 @@ class Dayswithqso_model extends CI_Model
return $query->result();
}
+ /*
+ * Returns the total number of QSOs made for each day of the week (Monday to Sunday)
+ */
+ function getMonthsOfYear() {
+ $this->load->model('logbooks_model');
+ $logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($this->session->userdata('active_station_logbook'));
+
+ if (!$logbooks_locations_array) {
+ return null;
+ }
+
+ $location_list = "'".implode("','",$logbooks_locations_array)."'";
+
+ $sql = "SELECT MONTHNAME(col_time_off) AS month, COUNT(*) AS qsos
+ FROM " . $this->config->item('table_name') . "
+ WHERE MONTH(col_time_off) BETWEEN 1 AND 12
+ AND station_id IN (" . $location_list . ")
+ GROUP BY month
+ ORDER BY FIELD(month, 'January', 'February', 'March', 'April', 'May', 'June',
+ 'July', 'August', 'September', 'October', 'November', 'December')";
+
+
+ $query = $this->db->query($sql);
+
+ return $query->result();
+ }
+
}
diff --git a/application/views/dayswithqso/index.php b/application/views/dayswithqso/index.php
index b5582371a..e10cfc69f 100644
--- a/application/views/dayswithqso/index.php
+++ b/application/views/dayswithqso/index.php
@@ -16,6 +16,9 @@
= __("Days of the week"); ?>
+
+ = __("Months of the year"); ?>
+
= __("Streaks"); ?>
@@ -61,6 +64,12 @@
+
+
+
= __('QSOs breakdown by month of the year'); ?>
+
+
+
= __("Longest streak with QSOs in the log"); ?>
diff --git a/assets/js/sections/dayswithqso.js b/assets/js/sections/dayswithqso.js
index c99d8849d..fc5061924 100644
--- a/assets/js/sections/dayswithqso.js
+++ b/assets/js/sections/dayswithqso.js
@@ -1,5 +1,6 @@
daysPerYear();
weekDays();
+months();
function daysPerYear() {
$.ajax({
@@ -108,3 +109,57 @@ function weekDays() {
}
});
}
+
+function months() {
+ $.ajax({
+ url: base_url + 'index.php/dayswithqso/get_months',
+ success: function (data) {
+ if ($.trim(data)) {
+ var labels = [];
+ var dataDays = [];
+ $.each(data, function () {
+ labels.push(this.month);
+ dataDays.push(this.qsos);
+ });
+ var ctx = document.getElementById("monthChart").getContext('2d');
+ var color = ifDarkModeThemeReturn('white', 'grey');
+ var myChart = new Chart(ctx, {
+ type: 'bar',
+ data: {
+ labels: labels,
+ datasets: [{
+ label: lang_qsos_this_weekday,
+ data: dataDays,
+ backgroundColor: 'rgba(54, 162, 235, 0.2)',
+ borderColor: 'rgba(54, 162, 235, 1)',
+ borderWidth: 2,
+ color: color
+ }]
+ },
+ options: {
+ scales: {
+ y: {
+ ticks: {
+ beginAtZero: true,
+ color: color
+ }
+ },
+ x: {
+ ticks: {
+ color: color
+ }
+ }
+ },
+ plugins: {
+ legend: {
+ labels: {
+ color: color
+ }
+ }
+ }
+ }
+ });
+ }
+ }
+ });
+}
From 1fe1b36a0740e842ebcc4b48be406bafe0238cdb Mon Sep 17 00:00:00 2001
From: Andreas Kristiansen <6977712+AndreasK79@users.noreply.github.com>
Date: Fri, 22 Nov 2024 16:20:17 +0100
Subject: [PATCH 2/2] Corrected some text in comment
---
application/models/Dayswithqso_model.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/application/models/Dayswithqso_model.php b/application/models/Dayswithqso_model.php
index 452ec7c77..518c1ef3c 100644
--- a/application/models/Dayswithqso_model.php
+++ b/application/models/Dayswithqso_model.php
@@ -201,7 +201,7 @@ class Dayswithqso_model extends CI_Model
}
/*
- * Returns the total number of QSOs made for each day of the week (Monday to Sunday)
+ * Returns the total number of QSOs made for each month of the year
*/
function getMonthsOfYear() {
$this->load->model('logbooks_model');
@@ -221,7 +221,6 @@ class Dayswithqso_model extends CI_Model
ORDER BY FIELD(month, 'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December')";
-
$query = $this->db->query($sql);
return $query->result();