{
  "db_name": "PostgreSQL",
  "query": "SELECT\n                WIDTH_BUCKET(\n                    EXTRACT(EPOCH FROM usa.created_at)::bigint,\n                    EXTRACT(EPOCH FROM $1::timestamp with time zone AT TIME ZONE 'UTC')::bigint,\n                    EXTRACT(EPOCH FROM $2::timestamp with time zone AT TIME ZONE 'UTC')::bigint,\n                    $3::integer\n                ) AS bucket,\n                CASE WHEN $5 THEN affiliate_code ELSE 0 END AS affiliate_code,\n                COUNT(*) AS conversions\n            FROM users_subscriptions_affiliations usa\n            INNER JOIN affiliate_codes ac ON ac.id = usa.affiliate_code\n            INNER JOIN users_subscriptions us ON us.id = usa.subscription_id\n            INNER JOIN charges c ON c.subscription_id = us.id\n            WHERE\n                ac.affiliate = $4\n                AND usa.created_at BETWEEN $1 AND $2\n                AND c.status = 'succeeded'\n            GROUP BY bucket, affiliate_code",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "bucket",
        "type_info": "Int4"
      },
      {
        "ordinal": 1,
        "name": "affiliate_code",
        "type_info": "Int8"
      },
      {
        "ordinal": 2,
        "name": "conversions",
        "type_info": "Int8"
      }
    ],
    "parameters": {
      "Left": [
        "Timestamptz",
        "Timestamptz",
        "Int4",
        "Int8",
        "Bool"
      ]
    },
    "nullable": [
      null,
      null,
      null
    ]
  },
  "hash": "9152c0d7e7f508491b601c16c6eed05e2333475e96007180acda6086ee2825c0"
}
