Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 03ef9e761a | |||
| ca1f8c976d | |||
| 7392709a27 | |||
| 623050478a |
+1
-1
@@ -47,7 +47,7 @@ htmlcov/
|
|||||||
.pylint.d/
|
.pylint.d/
|
||||||
|
|
||||||
# IDEs and editors
|
# IDEs and editors
|
||||||
#.vscode/
|
.vscode/
|
||||||
!.vscode/tasks.json
|
!.vscode/tasks.json
|
||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
.idea/
|
.idea/
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
TARGET=thechart
|
TARGET=thechart
|
||||||
VERSION=1.6.1
|
VERSION=1.7.4
|
||||||
ROOT=/home/will
|
ROOT=/home/will
|
||||||
ICON=chart-671.png
|
ICON=chart-671.png
|
||||||
SHELL=fish
|
SHELL=fish
|
||||||
@@ -85,7 +85,7 @@ install: ## Set up the development environment
|
|||||||
@echo "To run tests: make test"
|
@echo "To run tests: make test"
|
||||||
build: ## Build the Docker image
|
build: ## Build the Docker image
|
||||||
@echo "Building the Docker image..."
|
@echo "Building the Docker image..."
|
||||||
docker buildx build --platform linux/amd64,linux/arm64 -t ${IMAGE} --push .
|
docker buildx build --platform linux/amd64 -t ${IMAGE} --push .
|
||||||
deploy: ## Deploy the application as a standalone executable
|
deploy: ## Deploy the application as a standalone executable
|
||||||
@echo "Deploying the application..."
|
@echo "Deploying the application..."
|
||||||
pyinstaller --name ${TARGET} --optimize 2 --onefile --windowed --hidden-import='PIL._tkinter_finder' --icon='${ICON}' --add-data="./.env:." --add-data='./chart-671.png:.' --add-data='./thechart_data.csv:.' --log-level=DEBUG src/main.py
|
pyinstaller --name ${TARGET} --optimize 2 --onefile --windowed --hidden-import='PIL._tkinter_finder' --icon='${ICON}' --add-data="./.env:." --add-data='./chart-671.png:.' --add-data='./thechart_data.csv:.' --log-level=DEBUG src/main.py
|
||||||
|
|||||||
+3
-3
@@ -1,19 +1,19 @@
|
|||||||
#!/usr/bin/bash
|
#!/usr/bin/bash
|
||||||
|
|
||||||
CONTAINER_ENGINE="docker" # podman | docker
|
CONTAINER_ENGINE="docker" # podman | docker
|
||||||
VERSION="v1.0.0"
|
VERSION="v1.7.4"
|
||||||
REGISTRY="gitea-http.taildb3494.ts.net/will/thechart"
|
REGISTRY="gitea-http.taildb3494.ts.net/will/thechart"
|
||||||
|
|
||||||
if [ "$CONTAINER_ENGINE" == "podman" ];
|
if [ "$CONTAINER_ENGINE" == "podman" ];
|
||||||
then
|
then
|
||||||
buildah build \
|
buildah build \
|
||||||
-t $REGISTRY:$VERSION \
|
-t $REGISTRY:$VERSION \
|
||||||
--platform linux/amd64,linux/arm64/v8 \
|
--platform linux/amd64 \
|
||||||
--no-cache .
|
--no-cache .
|
||||||
else
|
else
|
||||||
DOCKER_BUILDKIT=1 \
|
DOCKER_BUILDKIT=1 \
|
||||||
docker buildx build \
|
docker buildx build \
|
||||||
--platform linux/amd64,linux/arm64/v8 \
|
--platform linux/amd64 \
|
||||||
-t $REGISTRY:$VERSION \
|
-t $REGISTRY:$VERSION \
|
||||||
--no-cache \
|
--no-cache \
|
||||||
--push .
|
--push .
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "thechart"
|
name = "thechart"
|
||||||
version = "1.6.1"
|
version = "1.7.4"
|
||||||
description = "Chart to monitor your medication intake over time."
|
description = "Chart to monitor your medication intake over time."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.13"
|
requires-python = ">=3.13"
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Test script to verify note field saving functionality
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
# Add src directory to path to import modules
|
||||||
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
||||||
|
|
||||||
|
from data_manager import DataManager
|
||||||
|
from medicine_manager import MedicineManager
|
||||||
|
from pathology_manager import PathologyManager
|
||||||
|
|
||||||
|
|
||||||
|
def test_note_saving():
|
||||||
|
"""Test note saving functionality by checking current data"""
|
||||||
|
print("Testing note saving functionality...")
|
||||||
|
|
||||||
|
# Initialize logger
|
||||||
|
logger = logging.getLogger("test")
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
# Initialize managers
|
||||||
|
medicine_manager = MedicineManager("medicines.json")
|
||||||
|
pathology_manager = PathologyManager("pathologies.json")
|
||||||
|
data_manager = DataManager(
|
||||||
|
"thechart_data.csv", logger, medicine_manager, pathology_manager
|
||||||
|
)
|
||||||
|
|
||||||
|
# Load current data
|
||||||
|
df = data_manager.load_data()
|
||||||
|
|
||||||
|
if df.empty:
|
||||||
|
print("No data found in CSV file")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"Found {len(df)} entries in the data file")
|
||||||
|
|
||||||
|
# Check if we have any entries with notes
|
||||||
|
entries_with_notes = df[df["note"].notna() & (df["note"] != "")].copy()
|
||||||
|
|
||||||
|
print(f"Entries with notes: {len(entries_with_notes)}")
|
||||||
|
|
||||||
|
if len(entries_with_notes) > 0:
|
||||||
|
print("\nEntries with notes:")
|
||||||
|
for _, row in entries_with_notes.iterrows():
|
||||||
|
note_preview = (
|
||||||
|
row["note"][:50] + "..." if len(str(row["note"])) > 50 else row["note"]
|
||||||
|
)
|
||||||
|
print(f" Date: {row['date']}, Note: {note_preview}")
|
||||||
|
|
||||||
|
# Show the most recent entry
|
||||||
|
if len(df) > 0:
|
||||||
|
latest_entry = df.iloc[-1]
|
||||||
|
print("\nMost recent entry:")
|
||||||
|
print(f" Date: {latest_entry['date']}")
|
||||||
|
print(f" Note: '{latest_entry['note']}'")
|
||||||
|
print(f" Note length: {len(str(latest_entry['note']))}")
|
||||||
|
is_empty = pd.isna(latest_entry["note"]) or latest_entry["note"] == ""
|
||||||
|
print(f" Note is empty/null: {is_empty}")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_note_saving()
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
Test the update_entry functionality with notes
|
||||||
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# Add src directory to path to import modules
|
||||||
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "src"))
|
||||||
|
|
||||||
|
from data_manager import DataManager
|
||||||
|
from medicine_manager import MedicineManager
|
||||||
|
from pathology_manager import PathologyManager
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_entry_with_note():
|
||||||
|
"""Test updating an entry with a note"""
|
||||||
|
print("Testing update_entry functionality with notes...")
|
||||||
|
|
||||||
|
# Initialize logger
|
||||||
|
logger = logging.getLogger("test")
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
# Add console handler to see debug output
|
||||||
|
handler = logging.StreamHandler()
|
||||||
|
handler.setLevel(logging.DEBUG)
|
||||||
|
formatter = logging.Formatter("%(levelname)s - %(message)s")
|
||||||
|
handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
# Initialize managers
|
||||||
|
medicine_manager = MedicineManager("medicines.json")
|
||||||
|
pathology_manager = PathologyManager("pathologies.json")
|
||||||
|
data_manager = DataManager(
|
||||||
|
"thechart_data.csv", logger, medicine_manager, pathology_manager
|
||||||
|
)
|
||||||
|
|
||||||
|
# Load current data
|
||||||
|
df = data_manager.load_data()
|
||||||
|
|
||||||
|
if df.empty:
|
||||||
|
print("No data found in CSV file")
|
||||||
|
return
|
||||||
|
|
||||||
|
print(f"Found {len(df)} entries in the data file")
|
||||||
|
|
||||||
|
# Find the most recent entry to test with
|
||||||
|
latest_entry = df.iloc[-1].copy()
|
||||||
|
original_date = latest_entry["date"]
|
||||||
|
|
||||||
|
print(f"Testing with entry: {original_date}")
|
||||||
|
print(f"Current note: '{latest_entry['note']}'")
|
||||||
|
|
||||||
|
# Create test values - keep everything the same but change the note
|
||||||
|
test_note = "This is a test note to verify saving functionality!"
|
||||||
|
|
||||||
|
# Build values list (same format as the UI would send)
|
||||||
|
values = [original_date] # date
|
||||||
|
|
||||||
|
# Add pathology values
|
||||||
|
pathology_keys = pathology_manager.get_pathology_keys()
|
||||||
|
for key in pathology_keys:
|
||||||
|
values.append(latest_entry.get(key, 0))
|
||||||
|
|
||||||
|
# Add medicine values and doses
|
||||||
|
medicine_keys = medicine_manager.get_medicine_keys()
|
||||||
|
for key in medicine_keys:
|
||||||
|
values.append(latest_entry.get(key, 0)) # medicine checkbox
|
||||||
|
values.append(latest_entry.get(f"{key}_doses", "")) # medicine doses
|
||||||
|
|
||||||
|
# Add the test note
|
||||||
|
values.append(test_note)
|
||||||
|
|
||||||
|
print(f"Values to save: {values}")
|
||||||
|
print(f"Note in values: '{values[-1]}'")
|
||||||
|
|
||||||
|
# Test the update
|
||||||
|
success = data_manager.update_entry(original_date, values)
|
||||||
|
|
||||||
|
if success:
|
||||||
|
print("Update successful!")
|
||||||
|
|
||||||
|
# Reload and verify
|
||||||
|
df_after = data_manager.load_data()
|
||||||
|
updated_entry = df_after[df_after["date"] == original_date].iloc[0]
|
||||||
|
|
||||||
|
print(f"Note after update: '{updated_entry['note']}'")
|
||||||
|
print(f"Note correctly saved: {updated_entry['note'] == test_note}")
|
||||||
|
|
||||||
|
# Reset the note back to original
|
||||||
|
values[-1] = latest_entry["note"]
|
||||||
|
data_manager.update_entry(original_date, values)
|
||||||
|
print("Reverted note back to original")
|
||||||
|
|
||||||
|
else:
|
||||||
|
print("Update failed!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
test_update_entry_with_note()
|
||||||
@@ -532,6 +532,7 @@ class UIManager:
|
|||||||
)
|
)
|
||||||
note_text.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
|
note_text.grid(row=0, column=0, sticky="ew", padx=5, pady=5)
|
||||||
note_text.insert("1.0", str(note))
|
note_text.insert("1.0", str(note))
|
||||||
|
vars_dict["note_text"] = note_text # Store the widget for access during save
|
||||||
|
|
||||||
# Bind text widget to string var for easy access
|
# Bind text widget to string var for easy access
|
||||||
def update_note(*args):
|
def update_note(*args):
|
||||||
@@ -1398,9 +1399,33 @@ class UIManager:
|
|||||||
|
|
||||||
# Get note text from Text widget
|
# Get note text from Text widget
|
||||||
note_text_widget = vars_dict.get("note_text")
|
note_text_widget = vars_dict.get("note_text")
|
||||||
|
self.logger.debug(f"note_text_widget found: {note_text_widget is not None}")
|
||||||
|
self.logger.debug(f"vars_dict keys: {list(vars_dict.keys())}")
|
||||||
|
|
||||||
note_content = ""
|
note_content = ""
|
||||||
if note_text_widget:
|
if note_text_widget:
|
||||||
|
try:
|
||||||
note_content = note_text_widget.get(1.0, tk.END).strip()
|
note_content = note_text_widget.get(1.0, tk.END).strip()
|
||||||
|
self.logger.debug(f"Note content from widget: '{note_content}'")
|
||||||
|
except Exception as e:
|
||||||
|
self.logger.error(f"Error getting note from text widget: {e}")
|
||||||
|
# Fallback to StringVar
|
||||||
|
note_var = vars_dict.get("note")
|
||||||
|
if note_var:
|
||||||
|
note_content = note_var.get()
|
||||||
|
self.logger.debug(
|
||||||
|
f"Note content from StringVar fallback: '{note_content}'"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
# Fallback to StringVar if note_text widget not found
|
||||||
|
note_var = vars_dict.get("note")
|
||||||
|
if note_var:
|
||||||
|
note_content = note_var.get()
|
||||||
|
self.logger.debug(f"Note content from StringVar: '{note_content}'")
|
||||||
|
else:
|
||||||
|
self.logger.error("No note widget or StringVar found!")
|
||||||
|
|
||||||
|
self.logger.debug(f"Final note_content: '{note_content}'")
|
||||||
|
|
||||||
# Extract dose data dynamically from all medicines
|
# Extract dose data dynamically from all medicines
|
||||||
dose_data = {}
|
dose_data = {}
|
||||||
|
|||||||
Reference in New Issue
Block a user