{
  "db_name": "PostgreSQL",
  "query": "\n            SELECT COALESCE(SUM(signed_amount), 0) as \"sum!\"\n            FROM (\n                -- Batch aggregates after the date\n                SELECT -ba.total_amount as signed_amount\n                FROM batch_aggregates ba\n                WHERE ba.user_id = $1\n                  AND ba.created_at > $2\n\n                UNION ALL\n\n                -- Non-batched transactions after the date\n                SELECT\n                    CASE WHEN ct.transaction_type IN ('admin_grant', 'purchase')\n                        THEN ct.amount\n                        ELSE -ct.amount\n                    END as signed_amount\n                FROM credits_transactions ct\n                WHERE ct.user_id = $1\n                  AND ct.fusillade_batch_id IS NULL\n                  AND ct.created_at > $2\n            ) after_date\n            ",
  "describe": {
    "columns": [
      {
        "ordinal": 0,
        "name": "sum!",
        "type_info": "Numeric"
      }
    ],
    "parameters": {
      "Left": [
        "Uuid",
        "Timestamptz"
      ]
    },
    "nullable": [
      null
    ]
  },
  "hash": "574ff94ce34d01f1dd226fe101787ab2072bb6d2b4fb8742386371d2342e6d7f"
}
