Skip to content
This repository has been archived by the owner on Nov 6, 2021. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:rubyforgood/partner
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmarcia committed May 1, 2020
2 parents ada6928 + 4a68385 commit f971dac
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/models/partner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def impact_metrics
{
families_served: families_served_count,
children_served: children_served_count,
family_zipcodes: family_zipcodes_count
family_zipcodes: family_zipcodes_count,
family_zipcodes_list: family_zipcodes_list
}
end

Expand Down Expand Up @@ -293,4 +294,8 @@ def children_served_count
def family_zipcodes_count
families.pluck(:guardian_zip_code).uniq.count
end

def family_zipcodes_list
families.pluck(:guardian_zip_code).uniq
end
end
3 changes: 3 additions & 0 deletions spec/models/partner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,12 @@

it "returns a hash with family and children aggregate data" do
partner = create(:partner, :with_families)
expect(partner.impact_metrics.size).to eq(4)
expect(partner.impact_metrics[:families_served]).to eq(1)
expect(partner.impact_metrics[:children_served]).to eq(1)
expect(partner.impact_metrics[:family_zipcodes]).to eq(1)
expect(partner.impact_metrics[:family_zipcodes_list]).to be_a(Array)
expect(partner.impact_metrics[:family_zipcodes_list]).to eq(partner.families.pluck(:guardian_zip_code).uniq)
end
end
end

0 comments on commit f971dac

Please sign in to comment.