Goalsystem V1 #50
|
|
@ -504,26 +504,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
|
||||||
with get_db() as conn:
|
with get_db() as conn:
|
||||||
cur = get_cursor(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("""
|
cur.execute("""
|
||||||
SELECT id, type_key, label_de, label_en, unit, icon, category,
|
SELECT id, type_key, label_de, label_en, unit, icon, category,
|
||||||
source_table, source_column, aggregation_method,
|
source_table, source_column, aggregation_method,
|
||||||
calculation_formula, description, is_system,
|
calculation_formula, description, is_system, is_active,
|
||||||
created_at, updated_at
|
created_at, updated_at
|
||||||
FROM goal_type_definitions
|
FROM goal_type_definitions
|
||||||
WHERE is_active = true
|
WHERE is_active = true
|
||||||
|
|
@ -535,9 +519,10 @@ def list_goal_type_definitions(session: dict = Depends(require_auth)):
|
||||||
label_de
|
label_de
|
||||||
""")
|
""")
|
||||||
|
|
||||||
return [r2d(row) for row in cur.fetchall()]
|
results = [r2d(row) for row in cur.fetchall()]
|
||||||
except HTTPException:
|
print(f"[DEBUG] Loaded {len(results)} goal types")
|
||||||
raise
|
return results
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[ERROR] list_goal_type_definitions failed: {e}")
|
print(f"[ERROR] list_goal_type_definitions failed: {e}")
|
||||||
print(traceback.format_exc())
|
print(traceback.format_exc())
|
||||||
|
|
|
||||||
|
|
@ -40,11 +40,14 @@ export default function AdminGoalTypesPage() {
|
||||||
|
|
||||||
const loadGoalTypes = async () => {
|
const loadGoalTypes = async () => {
|
||||||
setLoading(true)
|
setLoading(true)
|
||||||
|
setError(null)
|
||||||
try {
|
try {
|
||||||
const data = await api.listGoalTypeDefinitions()
|
const data = await api.listGoalTypeDefinitions()
|
||||||
setGoalTypes(data)
|
console.log('[DEBUG] Loaded goal types:', data)
|
||||||
|
setGoalTypes(data || [])
|
||||||
} catch (err) {
|
} 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 {
|
} finally {
|
||||||
setLoading(false)
|
setLoading(false)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user