Goalsystem V1 #50

Merged
Lars merged 51 commits from develop into main 2026-03-27 17:40:51 +01:00
2 changed files with 10 additions and 22 deletions
Showing only changes of commit 8be87bfdfb - Show all commits

View File

@ -504,26 +504,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
with get_db() as conn:
cur = get_cursor(conn)
# Check if table exists first
cur.execute("""
SELECT EXISTS (
SELECT FROM information_schema.tables
WHERE table_name = 'goal_type_definitions'
)
""")
table_exists = cur.fetchone()[0]
if not table_exists:
print("[ERROR] goal_type_definitions table does not exist!")
raise HTTPException(
status_code=500,
detail="Goal Types Tabelle existiert nicht. Migration 024 muss ausgeführt werden."
)
cur.execute("""
SELECT id, type_key, label_de, label_en, unit, icon, category,
source_table, source_column, aggregation_method,
calculation_formula, description, is_system,
calculation_formula, description, is_system, is_active,
created_at, updated_at
FROM goal_type_definitions
WHERE is_active = true
@ -535,9 +519,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
label_de
""")
return [r2d(row) for row in cur.fetchall()]
except HTTPException:
raise
results = [r2d(row) for row in cur.fetchall()]
print(f"[DEBUG] Loaded {len(results)} goal types")
return results
except Exception as e:
print(f"[ERROR] list_goal_type_definitions failed: {e}")
print(traceback.format_exc())

View File

@ -40,11 +40,14 @@ export default function AdminGoalTypesPage() {
const loadGoalTypes = async () => {
setLoading(true)
setError(null)
try {
const data = await api.listGoalTypeDefinitions()
setGoalTypes(data)
console.log('[DEBUG] Loaded goal types:', data)
setGoalTypes(data || [])
} catch (err) {
setError('Fehler beim Laden der Goal Types')
console.error('[ERROR] Failed to load goal types:', err)
setError(`Fehler beim Laden der Goal Types: ${err.message || err.toString()}`)
} finally {
setLoading(false)
}