feat: global quality filter setting (Issue #31)
Implemented global quality_filter_level in user profiles for consistent data filtering across all views (Dashboard, History, Charts, KI-Pipeline). Backend changes: - Migration 016: Add quality_filter_level column to profiles table - quality_filter.py: Centralized helper functions for SQL filtering - insights.py: Apply global filter in _get_profile_data() - activity.py: Apply global filter in list_activity() Frontend changes: - SettingsPage.jsx: Add Datenqualität section with 4-level selector - History.jsx: Use global quality filter from profile context Filter levels: all, quality (good+excellent+acceptable), very_good (good+excellent), excellent (only excellent) Closes #31 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
b317246bcd
commit
04306a7fef
6 files changed
+226
-10
No files matched your search
@@ -17,6 +17,7 @@ from db import get_db, get_cursor, r2d
|
||||
from auth import require_auth, require_admin, check_feature_access, increment_feature_usage
|
||||
from routers.profiles import get_pid
|
||||
from feature_logger import log_feature_usage
|
||||
from quality_filter import get_quality_filter_sql
|
||||
|
||||
router = APIRouter(prefix="/api", tags=["insights"])
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -67,6 +68,9 @@ def _get_profile_data(pid: str):
|
||||
cur = get_cursor(conn)
|
||||
cur.execute("SELECT * FROM profiles WHERE id=%s", (pid,))
|
||||
prof = r2d(cur.fetchone())
|
||||
|
||||
# Issue #31: Get global quality filter setting
|
||||
quality_filter = get_quality_filter_sql(prof)
|
||||
cur.execute("SELECT * FROM weight_log WHERE profile_id=%s ORDER BY date DESC LIMIT 90", (pid,))
|
||||
weight = [r2d(r) for r in cur.fetchall()]
|
||||
cur.execute("SELECT * FROM circumference_log WHERE profile_id=%s ORDER BY date DESC LIMIT 30", (pid,))
|
||||
@@ -75,13 +79,12 @@ def _get_profile_data(pid: str):
|
||||
caliper = [r2d(r) for r in cur.fetchall()]
|
||||
cur.execute("SELECT * FROM nutrition_log WHERE profile_id=%s ORDER BY date DESC LIMIT 90", (pid,))
|
||||
nutrition = [r2d(r) for r in cur.fetchall()]
|
||||
# Quality-Filter: nur hochwertige Aktivitäten für KI-Analyse (Issue #24)
|
||||
# TODO (#28): quality_level als Parameter (all, quality, very_good, excellent)
|
||||
# Zukünftig: GET /api/insights/run/{slug}?quality_level=quality
|
||||
cur.execute("""
|
||||
|
||||
# Issue #31: Global quality filter (from user profile setting)
|
||||
cur.execute(f"""
|
||||
SELECT * FROM activity_log
|
||||
WHERE profile_id=%s
|
||||
AND (quality_label IN ('excellent', 'good', 'acceptable') OR quality_label IS NULL)
|
||||
{quality_filter}
|
||||
ORDER BY date DESC LIMIT 90
|
||||
""", (pid,))
|
||||
activity = [r2d(r) for r in cur.fetchall()]
|
||||
|
||||
Reference in new issue
Block a user