{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/voltplan-app/json-schema/voltplan-app-admin-component-stats-schema.json",
  "title": "AdminComponentStats",
  "description": "Human affiliate clicks of one component (bot user agents excluded).",
  "x-generated": "2026-11-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/voltplan-app-openapi.json#/components/schemas/AdminComponentStats",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "total",
    "today",
    "last7Days",
    "last30Days",
    "byCountry",
    "bySource",
    "byApp",
    "dailyBuckets"
  ],
  "properties": {
    "total": {
      "type": "integer",
      "minimum": 0,
      "description": "All clicks, all time."
    },
    "today": {
      "type": "integer",
      "minimum": 0,
      "description": "Clicks since 00:00 UTC."
    },
    "last7Days": {
      "type": "integer",
      "minimum": 0,
      "description": "Clicks in the last 7 × 24 h."
    },
    "last30Days": {
      "type": "integer",
      "minimum": 0,
      "description": "Clicks in the last 30 × 24 h."
    },
    "byCountry": {
      "type": "object",
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      },
      "description": "Clicks by `resolved_country`; `unknown` when empty."
    },
    "bySource": {
      "type": "object",
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      },
      "description": "Clicks by `source`; `unknown` when empty."
    },
    "byApp": {
      "type": "object",
      "propertyNames": {
        "enum": [
          "voltplan",
          "cable",
          "blog",
          "calculator"
        ]
      },
      "additionalProperties": {
        "type": "integer",
        "minimum": 0
      },
      "description": "Clicks by app: the `source` prefix before `_` when it is a known app, else `voltplan`."
    },
    "dailyBuckets": {
      "type": "array",
      "minItems": 30,
      "maxItems": 30,
      "items": {
        "$ref": "#/$defs/AdminComponentStatsDay"
      },
      "description": "Last 30 UTC days, oldest first; the last entry is today."
    }
  },
  "$defs": {
    "AdminComponentStatsDay": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "date",
        "count"
      ],
      "properties": {
        "date": {
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
          "description": "UTC day."
        },
        "count": {
          "type": "integer",
          "minimum": 0
        }
      }
    }
  }
}