Remove unused imports and clean up code structure across multiple files
This commit is contained in:
@@ -13,7 +13,7 @@ from src import Icon
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
|
||||
@@ -13,7 +13,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
"logs/mail.log",
|
||||
rotation="1 day",
|
||||
|
||||
@@ -11,7 +11,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
f"logs/mail.log",
|
||||
enqueue=True,
|
||||
|
||||
@@ -7,7 +7,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
f"logs/settings.log",
|
||||
)
|
||||
|
||||
@@ -8,7 +8,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
|
||||
@@ -8,7 +8,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
logger.add(sys.stdout)
|
||||
|
||||
45
src/ui/widgets/admin_query.py
Normal file
45
src/ui/widgets/admin_query.py
Normal file
@@ -0,0 +1,45 @@
|
||||
from .widget_sources.admin_query_ui import Ui_Form
|
||||
|
||||
from PyQt6 import QtWidgets, QtCore
|
||||
from src import Icon
|
||||
from src.backend import Database
|
||||
|
||||
|
||||
class AdminQueryWidget(QtWidgets.QWidget, Ui_Form):
|
||||
def __init__(self, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setupUi(self)
|
||||
self.setWindowIcon(Icon("db_search").icon)
|
||||
self.db = Database()
|
||||
# Connect the button click to the method
|
||||
self.sendquery.clicked.connect(self.on_pushButton_clicked)
|
||||
|
||||
def on_pushButton_clicked(self):
|
||||
# Handle button click event
|
||||
self.queryResult.setRowCount(0) # Clear previous results
|
||||
request_text = self.sqlquery.toPlainText()
|
||||
if not request_text.strip():
|
||||
return
|
||||
|
||||
data = self.db.query_db(request_text)
|
||||
print(data)
|
||||
table_names = (
|
||||
request_text.lower().split("select")[1].split("from")[0].split(",")
|
||||
)
|
||||
table_names = [name.strip() for name in table_names]
|
||||
# reset the horizontal header labels
|
||||
self.queryResult.setHorizontalHeaderLabels(table_names)
|
||||
for result in data:
|
||||
row_position = self.queryResult.rowCount()
|
||||
self.queryResult.insertRow(row_position)
|
||||
for column, value in enumerate(result):
|
||||
item = QtWidgets.QTableWidgetItem(str(value))
|
||||
item.setFlags(item.flags() & ~QtCore.Qt.ItemFlag.ItemIsEditable)
|
||||
self.queryResult.setItem(row_position, column, item)
|
||||
|
||||
|
||||
def launch():
|
||||
app = QtWidgets.QApplication([])
|
||||
widget = AdminQueryWidget()
|
||||
widget.show()
|
||||
app.exec()
|
||||
@@ -15,7 +15,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add("logs/elsa_main.log", enqueue=True)
|
||||
logger.add(sys.stdout)
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add(
|
||||
"logs/graph.log",
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ from loguru import logger as log
|
||||
|
||||
logger = log
|
||||
logger.remove()
|
||||
logger.add("logs/application.log", rotation="1 week", enqueue=True)
|
||||
logger.add("logs/application.log", rotation="1 week", retention="1 month", enqueue=True)
|
||||
log.add("logs/searchPage.log", enqueue=True)
|
||||
|
||||
# logger.add(sys.stderr, format="{time} {level} {message}", level="INFO")
|
||||
@@ -46,7 +46,6 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.statistics_table.doubleClicked.connect(self.display_detailed_data)
|
||||
self.tabWidget_2.currentChanged.connect(self.tabW2_changed)
|
||||
self.btn_search.clicked.connect(self.statistics)
|
||||
self.book_search.clicked.connect(self.search_book)
|
||||
self.tableWidget.customContextMenuRequested.connect(
|
||||
self.statistics_table_context_menu
|
||||
)
|
||||
@@ -69,6 +68,8 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
# set tableWidget column 0 to be 50px wide
|
||||
self.tableWidget.setColumnWidth(0, 50)
|
||||
self.semester = Semester().value
|
||||
self.search_by_signature.returnPressed.connect(self.search_book)
|
||||
self.search_by_title.returnPressed.connect(self.search_book)
|
||||
self.populate_tab()
|
||||
|
||||
def restore_apparat(self):
|
||||
@@ -143,7 +144,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
|
||||
def search_book(self):
|
||||
self.book_search_result.setRowCount(0)
|
||||
signature = self.seach_by_signature.text()
|
||||
signature = self.search_by_signature.text()
|
||||
title = self.search_by_title.text()
|
||||
params = {
|
||||
"signature": signature if signature != "" else None,
|
||||
@@ -155,6 +156,7 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
if retdata is None:
|
||||
return
|
||||
for book in retdata:
|
||||
logger.debug(book)
|
||||
self.book_search_result.insertRow(0)
|
||||
self.book_search_result.setItem(
|
||||
0, 0, QtWidgets.QTableWidgetItem(book[0].title)
|
||||
@@ -166,7 +168,12 @@ class SearchStatisticPage(QtWidgets.QDialog, Ui_Dialog):
|
||||
self.book_search_result.setItem(
|
||||
0,
|
||||
2,
|
||||
QtWidgets.QTableWidgetItem(self.db.getApparatName(book[1], book[2])),
|
||||
QtWidgets.QTableWidgetItem(
|
||||
self.db.fetch_one(
|
||||
"SELECT semesterapparat.appnr || ' (' || semesterapparat.name || ')' AS formatted_result from semesterapparat WHERE semesterapparat.appnr = ?",
|
||||
(book[1],),
|
||||
)[0],
|
||||
),
|
||||
)
|
||||
|
||||
def notify_for_deletion(self):
|
||||
|
||||
Reference in New Issue
Block a user