{
  "status": "approved",
  "source_system": "cake",
  "environment": [
    "staging",
    "prod"
  ],
  "sharded": true,
  "shard_schema": "lucos_ro_cake",
  "id": "get_publisher_conversion_report",
  "mcp_tool": "get_publisher_conversion_report",
  "shard_view_prefix": "lucos_ro_conv_mapping",
  "connections": {
    "admin": "cake_admin_ro",
    "shorty": "cake_shorty_ro"
  },
  "objects": [
    "lucos_ro_cake.lucos_ro_conv_mapping_*",
    "Admin.lucos_ro_affiliate_directory",
    "Admin.lucos_ro_campaign_directory"
  ],
  "parameters": {
    "publisher": {
      "type": "string",
      "required": true
    },
    "group_by": {
      "type": "enum",
      "required": false,
      "default": "advertiser",
      "values": [
        "advertiser",
        "day",
        "click"
      ]
    },
    "date_from": {
      "type": "date",
      "required": false
    },
    "date_to": {
      "type": "date",
      "required": false
    },
    "limit": {
      "type": "int",
      "required": false,
      "default": 50
    }
  },
  "constraints": {
    "max_window_days": 92,
    "default_window_days": 30,
    "max_rows": 500,
    "timeout_ms": 60000
  },
  "allow_fields": [
    "date",
    "adv_id",
    "adv_name",
    "camp_id",
    "campaign_name",
    "admedia_click_id",
    "orders",
    "sales_amount",
    "revenue",
    "clicks_with_conversions"
  ],
  "deny_fields": [
    "publisher_click_id",
    "publisher_sub_id",
    "search_term",
    "ip",
    "click_ip",
    "rev_share",
    "net_cpc"
  ],
  "post_processing": [
    "Answers members.admedia.com Conversion Report By ClickID (reports/conversion_mapping, stats_model.php getConversionMappings line 2919).",
    "Reads monthly lucos_ro_cake.lucos_ro_conv_mapping_YYYYMM views over Shorty conversion_mapping_data_YYYYMM, filtered to the publisher.",
    "REPRODUCES A PORTAL BUG: the monthly tables are joined with UNION, not UNION ALL (stats_model.php:2931-2936). With two or more months MySQL dedups the WHOLE combined result, so identical conversion rows collapse - including duplicates inside a single month - and totals can read lower than the same days queried a month at a time. With exactly one month the portal builds no UNION and dedups nothing. The asymmetry is reproduced exactly; the response reports which case applied in `deduped`.",
    "group_by=click returns ONE ROW PER SOURCE ROW with no aggregation, because the portal's own grain is the raw select plus a PHP decoration loop (stats_model.php:2926-2928, :2944-2954).",
    "adv_name and campaign_name come from Admin.lucos_ro_campaign_directory, the approved view over the campaign JOIN Advertiser_info that stats_model.php:2947-2948 queries one row at a time. adv_name is keyed on the conversion row's own adv_id. Admin.lucos_ro_advertiser is deliberately NOT used: it is granted to lucos_mngt_ro only, and this tool reads Admin as cake_admin_ro.",
    "revenue is 0 on every row, which is the portal's own value and not a placeholder: stats_model.php:2953 pays out only when the AdMedia click id decrypts to a publisher click id and forces a literal 0 when it does not. Decryption runs in PHP (decrypt_clickId, falling back to whale clickid_information_YYYYMMDD), so no row read through a SQL view can ever have one.",
    "LIMITATION, stated in every response: the publisher's own click id, sub id and search term are unavailable, for the same decryption reason."
  ],
  "notes": "Conversions (orders and sales amount) for a publisher by advertiser, day or AdMedia click id, with advertiser and campaign names. Publisher is mandatory."
}
