Given the following select:
SELECT
COUNT(*) AS total,
SUM(CASE approved WHEN 't' THEN 1 ELSE 0 END) AS num_approved,
SUM(CASE soft_delete WHEN 't' THEN 1 ELSE 0 END) AS num_deleted
FROM model_name;
How might I translate this into something in my class ModelName definition, so that I can retrieve the values of total, num_approved, and num_deleted in my Rails application? I'm happy with any output (array, hash, accessors on a ModelName object) that puts the numbers at the Ruby level.