{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/revyl/main/json-schema/revyl-dashboard-metrics-schema.json",
  "title": "DashboardMetrics",
  "description": "Model representing dashboard metrics with week-over-week comparisons.",
  "x-generated": "2026-10-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/revyl-openapi.json#/components/schemas/DashboardMetrics",
  "properties": {
    "analytics_degraded": {
      "default": false,
      "description": "Whether the eventual-consistency analytics lane was unavailable for this response. When true, execution aggregates and week-over-week comparisons (test_runs, tests_failing_*, avg_test_duration*, success/failure_run_count, workflow_run_count, *_wow) are placeholders rather than measurements, while onboarding, billing, and Atlas facts remain current. Clients must render those analytics as unavailable instead of zero.",
      "title": "Analytics Degraded",
      "type": "boolean"
    },
    "atlas_generation_running": {
      "default": false,
      "description": "Whether an Atlas exploration run is currently queued/running. Drives the 'map is building' onboarding state and defers session-based activation while generating.",
      "title": "Atlas Generation Running",
      "type": "boolean"
    },
    "avg_test_duration": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Average test execution duration in seconds",
      "title": "Avg Test Duration"
    },
    "avg_test_duration_wow": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Week-over-week percentage change in average duration (positive = increase)",
      "title": "Avg Test Duration Wow"
    },
    "checklist_app_uploaded": {
      "default": false,
      "description": "Whether the user has uploaded an app (checklist step 1).",
      "title": "Checklist App Uploaded",
      "type": "boolean"
    },
    "checklist_session_started": {
      "default": false,
      "description": "Whether the user has started a device session (checklist step 2).",
      "title": "Checklist Session Started",
      "type": "boolean"
    },
    "checklist_test_created": {
      "default": false,
      "description": "Whether the user has created a test (checklist step 3).",
      "title": "Checklist Test Created",
      "type": "boolean"
    },
    "connected_integrations": {
      "description": "List of connected integration IDs (e.g. 'github', 'slack', 'expo'). Used for bonus session nudges.",
      "items": {
        "type": "string"
      },
      "title": "Connected Integrations",
      "type": "array"
    },
    "dashboard_state": {
      "default": "mature",
      "description": "Dashboard view state: onboarding (checklist incomplete), intermediate (checklist done but no active plan), mature (fully active)",
      "enum": [
        "onboarding",
        "intermediate",
        "mature"
      ],
      "title": "Dashboard State",
      "type": "string"
    },
    "failure_run_count": {
      "default": 0,
      "description": "Total number of failed test execution runs.",
      "title": "Failure Run Count",
      "type": "integer"
    },
    "has_atlas_map": {
      "default": false,
      "description": "Whether the org has a renderable Atlas map (any exploration run with atlas_status completed/partial). Own-milestone fact for the atlas onboarding lens.",
      "title": "Has Atlas Map",
      "type": "boolean"
    },
    "has_exploration": {
      "default": false,
      "description": "Whether the org has started any Atlas exploration, in any state. Hides the post-setup offer to map the app.",
      "title": "Has Exploration",
      "type": "boolean"
    },
    "org_has_apps": {
      "default": false,
      "description": "Whether the org has any user-uploaded apps (controls whether 'upload app' step is shown).",
      "title": "Org Has Apps",
      "type": "boolean"
    },
    "success_run_count": {
      "default": 0,
      "description": "Total number of completed (passed) test execution runs.",
      "title": "Success Run Count",
      "type": "integer"
    },
    "test_runs": {
      "description": "Total number of test executions",
      "title": "Test Runs",
      "type": "integer"
    },
    "test_runs_wow": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Week-over-week percentage change in test runs (positive = increase)",
      "title": "Test Runs Wow"
    },
    "tests_failing_count": {
      "description": "Raw number of tests currently failing",
      "title": "Tests Failing Count",
      "type": "integer"
    },
    "tests_failing_count_wow": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Week-over-week percentage change in failing tests count (positive = increase)",
      "title": "Tests Failing Count Wow"
    },
    "tests_failing_percent": {
      "description": "Percentage of tests currently failing",
      "title": "Tests Failing Percent",
      "type": "number"
    },
    "tests_failing_percent_wow": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Week-over-week percentage point change in failing tests percentage (positive = increase)",
      "title": "Tests Failing Percent Wow"
    },
    "total_tests": {
      "description": "Total number of tests",
      "title": "Total Tests",
      "type": "integer"
    },
    "total_tests_wow": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Week-over-week percentage change in total tests (positive = increase)",
      "title": "Total Tests Wow"
    },
    "total_workflows": {
      "description": "Total number of workflows",
      "title": "Total Workflows",
      "type": "integer"
    },
    "total_workflows_wow": {
      "anyOf": [
        {
          "type": "number"
        },
        {
          "type": "null"
        }
      ],
      "description": "Week-over-week percentage change in total workflows (positive = increase)",
      "title": "Total Workflows Wow"
    },
    "workflow_run_count": {
      "default": 0,
      "description": "Total workflow executions for the org (controls workflow slot visibility)",
      "title": "Workflow Run Count",
      "type": "integer"
    }
  },
  "required": [
    "total_tests",
    "test_runs",
    "tests_failing_percent",
    "tests_failing_count",
    "avg_test_duration",
    "total_workflows"
  ],
  "type": "object"
}