Skip to content

Commit

Permalink
@mbridak get rate window to auto update.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbridak committed Jan 14, 2025
1 parent 0c8a9da commit a5e557e
Showing 1 changed file with 46 additions and 2 deletions.
48 changes: 46 additions & 2 deletions not1mm/ratewindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
# pylint: disable=no-name-in-module, unused-import, no-member, invalid-name, c-extension-no-member
# pylint: disable=logging-fstring-interpolation, line-too-long

import datetime
import time
import logging
import os

from PyQt6 import uic
from PyQt6.QtWidgets import QLabel, QVBoxLayout, QWidget, QDockWidget
from PyQt6.QtWidgets import QLabel, QWidget, QDockWidget
from PyQt6.QtGui import QMouseEvent, QColorConstants, QPalette, QColor
from PyQt6.QtCore import pyqtSignal
from PyQt6.QtCore import pyqtSignal, QTimer

import not1mm.fsutils as fsutils
from not1mm.lib.database import DataBase
Expand All @@ -33,6 +35,7 @@ class RateWindow(QDockWidget):
message = pyqtSignal(dict)
dbname = None
pref = {}
poll_time = datetime.datetime.now() + datetime.timedelta(milliseconds=1000)

def __init__(self):
super().__init__()
Expand All @@ -45,6 +48,9 @@ def __init__(self):
self.database.current_contest = self.pref.get("contest", 0)

uic.loadUi(fsutils.APP_DATA_PATH / "ratewindow.ui", self)
self.timer = QTimer()
self.timer.timeout.connect(self.get_run_and_total_qs)
self.timer.start(1000)

def msg_from_main(self, packet):
""""""
Expand Down Expand Up @@ -128,3 +134,41 @@ def load_pref(self) -> None:
except (IOError, JSONDecodeError) as exception:
logger.critical("Error: %s", exception)
self.setDarkMode(self.pref.get("darkmode", False))

def get_run_and_total_qs(self):
"""get numbers"""

# last_hour
# 10_last_qso
# hundred_last_qso
# since_starttime
# --------------------
# time_on
# time_off
# --------------------
# run_qso
# sandp_qso
# hour_run_qso
# hour_sandp_qso
# --------------------
# avg_km
# avg_pts
# --------------------
# time_by_mult
# qso_counts
# mult_counts
# mult_worth
# {'runs': 3, 'totalqs': 3}

# WHERE datetime(timestamp) > datetime(current_timestamp, '-60 minutes')
if self.active:
query = f"select sum(IsRunQSO) as runs, count(*) as totalqs from dxlog where ContestNR = {self.database.current_contest};"
result = self.database.exec_sql(query)
sandp = result.get("totalqs", 0) - result.get("runs", 0)
self.run_qso.setText(f"{result.get("runs", 0)}")
self.sandp_qso.setText(f"{sandp}")
self.qso_counts.setText(f"{result.get("totalqs", 0)} pts")

query = f"select count(*) as totalqs from dxlog where ContestNR = {self.database.current_contest} and datetime(TS) > datetime(current_timestamp, '-60 minutes');"
result = self.database.exec_sql(query)
self.last_hour.setText(f"{result.get("totalqs", 0)} Q/h")

0 comments on commit a5e557e

Please sign in to comment.