44 lines
1.7 KiB
Python
44 lines
1.7 KiB
Python
from __future__ import annotations
|
|
|
|
from app.services.catalog import MetricCatalog, get_catalog
|
|
|
|
|
|
|
|
def build_capabilities(catalog: MetricCatalog | None = None) -> dict:
|
|
catalog = catalog or get_catalog()
|
|
settings = catalog.settings
|
|
|
|
string_rows = []
|
|
for item in settings.strings:
|
|
metric_ids = list(item.get("metrics", {}).values())
|
|
if any(catalog.safe_get(metric_id) for metric_id in metric_ids):
|
|
string_rows.append(item)
|
|
|
|
analytics_enabled = settings.modules.get("analytics", False)
|
|
|
|
return {
|
|
"modules": settings.modules,
|
|
"strings_enabled": settings.modules.get("strings", False) and len(string_rows) > 0,
|
|
"strings_count": len(string_rows),
|
|
"phases_enabled": False,
|
|
"phases_count": 0,
|
|
"analytics_enabled": analytics_enabled,
|
|
"realtime_enabled": settings.modules.get("realtime_overview", False),
|
|
"comparison_modes": list(settings.analytics["compare_modes"].keys()),
|
|
"ranges": [
|
|
{"key": key, "label": definition["label"]}
|
|
for key, definition in settings.time_ranges.items()
|
|
],
|
|
"buckets": [
|
|
{"key": key, "label": label}
|
|
for key, label in settings.analytics["bucket_labels"].items()
|
|
],
|
|
"historical_import_enabled": settings.modules.get("historical_import", False),
|
|
"history": {
|
|
"enabled": settings.history.get("enabled", True),
|
|
"default_chunk_days": settings.history.get("default_chunk_days", 7),
|
|
"auto_sync_enabled": settings.history.get("auto_sync_enabled", False),
|
|
"auto_sync_interval_minutes": settings.history.get("auto_sync_interval_minutes", 30),
|
|
},
|
|
}
|