Sha256: 5ba305dac8af0379bd78bdceb33b0938d6767e84f1815687a9f57f75118011b0

Contents?: true

Size: 862 Bytes

Versions: 2

Compression:

Stored size: 862 Bytes

Contents

class CreateNeighborAdminFundingRaisedPerProjectReports < ActiveRecord::Migration
  def up
    execute <<-SQL
        CREATE OR REPLACE VIEW neighborly_admin_funding_raised_per_project_reports AS
        SELECT
          project.id AS project_id,
          project.name AS project_name,
          sum(contributions.value) AS total_raised,
          count(*) AS total_backs,
          count(DISTINCT contributions.user_id) AS total_backers
         FROM contributions
         JOIN projects AS project ON project.id = contributions.project_id
        WHERE contributions.state::text <> ALL (ARRAY['waiting_confirmation'::character varying::text, 'pending'::character varying::text, 'canceled'::character varying::text, 'deleted'])
        GROUP BY project.id;
    SQL
  end

  def down
    drop_view :neighborly_admin_funding_raised_per_project_reports
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dune-admin-1.2.1 db/migrate/20141005184741_create_neighbor_admin_funding_raised_per_project_reports.rb
dune-admin-1.2.0 db/migrate/20141005184741_create_neighbor_admin_funding_raised_per_project_reports.rb