From a87bc307635fad85e989b5aa68406f3cf8161758 Mon Sep 17 00:00:00 2001 From: Keith Walters Date: Sun, 6 Sep 2020 15:28:49 -0400 Subject: [PATCH 1/9] WIP: Basic scaffold for CommunityResourceImporter This creates a new CommunityResourceImporter class which can be used to import CSV data and create CommunityResource objects and it's associated relationships. At the moment this only creates the primary class and sets the name property. There is still a lot more work to do, but what exists works and IT HAS TESTS!!! --- .../importers/community_resource_importer.rb | 10 ++++++ .../community_resource_importer_spec.rb | 35 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 app/models/importers/community_resource_importer.rb create mode 100644 spec/models/importers/community_resource_importer_spec.rb diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb new file mode 100644 index 000000000..ef53bae97 --- /dev/null +++ b/app/models/importers/community_resource_importer.rb @@ -0,0 +1,10 @@ +class Importers::CommunityResourceImporter < Importers::BaseImporter + def primary_import_klass_name + "CommunityResource" + end + + def process_row(row) + puts "Pair programming @ RFG!!!" + CommunityResource.create! name: row["name"] + end +end \ No newline at end of file diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb new file mode 100644 index 000000000..4796eae4e --- /dev/null +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -0,0 +1,35 @@ +require 'rails_helper' + +RSpec.describe Importers::CommunityResourceImporter do + let(:user) { User.new } + subject { Importers::CommunityResourceImporter.new(user) } + + let(:single_record) { + <<~CSV + category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,,,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + CSV + } + + before do + # Do nothing + end + + after do + # Do nothing + end + + context 'when given a row of csv data' do + it 'creates a single CommunityResource in the database' do + expect { + subject.import_string single_record + }.to change { CommunityResource.count }.from(0).to(1) + end + + it 'creates a CommunityResource with a name' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.name).to eq 'Food Vouchers' + end + end +end \ No newline at end of file From e41ddc25654f3cf8ccb455a83efa297a52f7aa75 Mon Sep 17 00:00:00 2001 From: senadakadric Date: Sun, 6 Sep 2020 16:06:46 -0400 Subject: [PATCH 2/9] created tests for website, facebook, phone, description, organization for the community resource importer --- .../importers/community_resource_importer.rb | 6 ++- .../community_resource_importer_spec.rb | 37 +++++++++++++++++++ spec/models/offer_spec.rb | 11 ++++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb index ef53bae97..5dc701310 100644 --- a/app/models/importers/community_resource_importer.rb +++ b/app/models/importers/community_resource_importer.rb @@ -5,6 +5,10 @@ def primary_import_klass_name def process_row(row) puts "Pair programming @ RFG!!!" - CommunityResource.create! name: row["name"] + comm_resource = CommunityResource.create! name: row["name"], website_url: row["website_url"], facebook_url: row["facebook_url"], phone: row["phone"], description: row["description"] + + comm_resource.organization = Organization.create! name: row["organization_name"] + # comm_resource.location = Location.create! street_address: row["street"] + comm_resource.save end end \ No newline at end of file diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb index 4796eae4e..a120c03a8 100644 --- a/spec/models/importers/community_resource_importer_spec.rb +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -31,5 +31,42 @@ resource = CommunityResource.last expect(resource.name).to eq 'Food Vouchers' end + + it 'creates a CommunityResource with a website_url' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.website_url).to eq 'https://example.com' + end + + it 'creates a CommunityResource with a facebook_url' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.facebook_url).to eq 'https://facebook.com/sample' + end + + it 'creates a CommunityResource with a phone' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.phone).to eq '818-555-9876' + end + + it 'creates a CommunityResource with a description' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.description).to eq 'A long description of text.' + end + + it 'creates a CommunityResource with an organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.name).to eq "WIC" + end + + # failing bc needs location type but we dont know what type it is + # it 'creates a CommunityResource with a location street' do + # subject.import_string single_record + # resource = CommunityResource.last + # expect(resource.location.street_address).to eq "123 Main Street" + # end end end \ No newline at end of file diff --git a/spec/models/offer_spec.rb b/spec/models/offer_spec.rb index 5c28d3975..ab09ba733 100644 --- a/spec/models/offer_spec.rb +++ b/spec/models/offer_spec.rb @@ -20,4 +20,15 @@ expect(Offer.matchable).to eq([unmatched_offer]) end end + + describe 'create' do + it 'sets an offer inexhaustable if there is a system setting for it' do + SystemSetting.any_instance.should_receive(:inexhaustable_by_default?).returns(true) + + offer = Offer.create! + + expect(offer.inexhaustable).to eq(true) + end + end + end From b5818ffc18c6fe2fab2adf163b4d979a211a9bd1 Mon Sep 17 00:00:00 2001 From: Keith Walters Date: Sat, 12 Sep 2020 12:29:55 -0400 Subject: [PATCH 3/9] WIP: Import location and Service Area for Community Resource This adds the location and service area models to the community resource being imported. --- .../importers/community_resource_importer.rb | 24 ++++- .../community_resource_importer_spec.rb | 89 +++++++++++++++++-- 2 files changed, 104 insertions(+), 9 deletions(-) diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb index 5dc701310..014a76e61 100644 --- a/app/models/importers/community_resource_importer.rb +++ b/app/models/importers/community_resource_importer.rb @@ -8,7 +8,29 @@ def process_row(row) comm_resource = CommunityResource.create! name: row["name"], website_url: row["website_url"], facebook_url: row["facebook_url"], phone: row["phone"], description: row["description"] comm_resource.organization = Organization.create! name: row["organization_name"] - # comm_resource.location = Location.create! street_address: row["street"] + business_location = LocationType.find_or_create_by(name: "business") + comm_resource.location = Location.create! do |location| + location.street_address = row["street"] + location.city = row["city"] + location.state = row["state"] + location.zip = row["zip"] + location.county = row["county"] + location.location_type = business_location + end + + service_location_type = LocationType.find_or_create_by(name: "service_area") + comm_resource.service_area = ServiceArea.create! do |service_area| + service_area.name = "Test Service Area" + service_area.service_area_type = "unknown" + service_area.organization = comm_resource.organization + service_area.location = Location.create! do |location| + location.location_type = service_location_type + location.city = row["city"] + location.state = row["state"] + location.county = row["county"] + end + end + comm_resource.save end end \ No newline at end of file diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb index a120c03a8..a0a8d4c5f 100644 --- a/spec/models/importers/community_resource_importer_spec.rb +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -6,8 +6,8 @@ let(:single_record) { <<~CSV - category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description - food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,,,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,,,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. CSV } @@ -62,11 +62,84 @@ expect(resource.organization.name).to eq "WIC" end - # failing bc needs location type but we dont know what type it is - # it 'creates a CommunityResource with a location street' do - # subject.import_string single_record - # resource = CommunityResource.last - # expect(resource.location.street_address).to eq "123 Main Street" - # end + it 'creates a CommunityResource with a business location type' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.location.location_type.name).to eq "business" + end + + it 'creates a CommunityResource with a location street' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.location.street_address).to eq "123 Main Street" + end + + it 'creates a CommunityResource with a location city' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.location.city).to eq "Springfield" + end + + it 'creates a CommunityResource with a location state' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.location.state).to eq "XY" + end + + it 'creates a CommunityResource with a location zip' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.location.zip).to eq "12345" + end + + it 'creates a CommunityResource with a location county' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.location.county).to eq "Queens County" + end + + context "when service area location is not provided" do + it "sets the service area name from the community resource location" do + pending "What should the name be set to if it's not provided?" + subject.import_string single_record + resource = CommunityResource.last + expect(resource.service_area.name).to eq "Unknown" + end + + it "sets the service area location city from the community resource location" do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.service_area.location.city).to eq "Springfield" + end + + it "sets the service area location state from the community resource location" do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.service_area.location.state).to eq "XY" + end + + it "sets the service area location county from the community resource location" do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.service_area.location.county).to eq "Queens County" + end + + it "sets the service area location type" do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.service_area.location.location_type.name).to eq "service_area" + end + end + + context "when service area location is provided" do + let(:single_record_with_service_area) { + <<~CSV + category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,Sunny Side,"Queens County, Brooklyn",,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + CSV + } + + + end end end \ No newline at end of file From 76151784fa7f017eb75765a7374998689eca0f75 Mon Sep 17 00:00:00 2001 From: senadakadric Date: Sat, 12 Sep 2020 15:49:59 -0400 Subject: [PATCH 4/9] created tests for all fields --- .../importers/community_resource_importer.rb | 29 ++++- .../community_resource_importer_spec.rb | 113 +++++++++++++++++- 2 files changed, 131 insertions(+), 11 deletions(-) diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb index 014a76e61..cfdfba91c 100644 --- a/app/models/importers/community_resource_importer.rb +++ b/app/models/importers/community_resource_importer.rb @@ -5,7 +5,9 @@ def primary_import_klass_name def process_row(row) puts "Pair programming @ RFG!!!" - comm_resource = CommunityResource.create! name: row["name"], website_url: row["website_url"], facebook_url: row["facebook_url"], phone: row["phone"], description: row["description"] + comm_resource = CommunityResource.create! name: row["name"], website_url: row["website_url"], facebook_url: row["facebook_url"], phone: row["phone"], description: row["description"], youtube_identifier: row["youtube_identifier"], publish_from: row["publish_from"], publish_until: row["publish_until"], is_created_by_admin: row["is_created_by_admin"], is_approved: row["is_approved"] + + comm_resource.tag_list.add(row["category_name"]) comm_resource.organization = Organization.create! name: row["organization_name"] business_location = LocationType.find_or_create_by(name: "business") @@ -20,14 +22,31 @@ def process_row(row) service_location_type = LocationType.find_or_create_by(name: "service_area") comm_resource.service_area = ServiceArea.create! do |service_area| - service_area.name = "Test Service Area" - service_area.service_area_type = "unknown" + if row["service_area_name"] + service_area.name = row["service_area_name"] + elsif row["service_area_town_names"] + service_area.name = row["service_area_town_names"] + elsif row["service_area_counties"] + service_area.name = row["service_area_counties"] + else + service_area.name = row["city"] + end + + if row["service_area_counties"] + service_area.service_area_type = "county" + else + service_area.service_area_type = "city" + end + service_area.organization = comm_resource.organization service_area.location = Location.create! do |location| location.location_type = service_location_type - location.city = row["city"] + + location.city = row["service_area_town_names"] ? row["service_area_town_names"] : row["city"] + location.state = row["state"] - location.county = row["county"] + + location.county = row["service_area_counties"] ? row["service_area_counties"] : row["county"] end end diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb index a0a8d4c5f..ba2bf1aab 100644 --- a/spec/models/importers/community_resource_importer_spec.rb +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -7,7 +7,7 @@ let(:single_record) { <<~CSV category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description - food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,,,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,,,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,2020-09-10,FALSE,FALSE,dQw4w9WgXcQ,A long description of text. CSV } @@ -98,12 +98,48 @@ expect(resource.location.county).to eq "Queens County" end + it 'creates a CommunityResource with a youtube identifier' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.youtube_identifier).to eq "dQw4w9WgXcQ" + end + + it 'creates a CommunityResource with a publish_from' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.publish_from).to eq "2020-09-05".to_date + end + + it 'creates a CommunityResource with a publish_until' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.publish_until).to eq "2020-09-10".to_date + end + + it 'creates a CommunityResource with a is_created_by_admin' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.is_created_by_admin).to eq false + end + + it 'creates a CommunityResource with a is_approved' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.is_approved).to eq false + end + + + it 'sets the tag on the Community Resource using the category_name' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.tag_list).to eq ['food'] + end + context "when service area location is not provided" do - it "sets the service area name from the community resource location" do - pending "What should the name be set to if it's not provided?" + it "sets the service area name from the community resource location city" do subject.import_string single_record resource = CommunityResource.last - expect(resource.service_area.name).to eq "Unknown" + expect(resource.service_area.name).to eq "Springfield" end it "sets the service area location city from the community resource location" do @@ -131,15 +167,80 @@ end end - context "when service area location is provided" do + context "when service area name is provided" do let(:single_record_with_service_area) { <<~CSV category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description - food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,Sunny Side,"Queens County, Brooklyn",,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,Sunny Side,,,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + CSV + } + + it 'sets the service area name from the service_area_name if it is provided' do + subject.import_string single_record_with_service_area + resource = CommunityResource.last + + expect(resource.service_area.name).to eq "Sunny Side" + end + + it 'sets the service area type' do + subject.import_string single_record_with_service_area + resource = CommunityResource.last + + expect(resource.service_area.service_area_type).to eq "city" + end + end + + context "when service area town name is provided and service area name is not" do + let(:single_record_with_service_area_town_name) { + <<~CSV + category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,"Queens County, Brooklyn","Glens Falls, Queensbury",818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. + CSV + } + + it 'sets the service area name from the service_area_town_names if service_area_name is not provided' do + subject.import_string single_record_with_service_area_town_name + resource = CommunityResource.last + + expect(resource.service_area.name).to eq "Glens Falls, Queensbury" + end + + it 'checks to see if service area location city is set to the town names' do + subject.import_string single_record_with_service_area_town_name + resource = CommunityResource.last + + expect(resource.service_area.location.city).to eq "Glens Falls, Queensbury" + end + end + + context "when service area counties are provided and service area names and town names are not" do + let(:single_record_with_service_area_counties) { + <<~CSV + category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description + food,Food Vouchers,WIC,123 Main Street,Springfield,XY,12345,Queens County,,"Queens County, Brooklyn",,818-555-9876,https://example.com,https://facebook.com/sample,2020-09-05,,TRUE,TRUE,,A long description of text. CSV } + it 'sets the service area name from the service_area_counties if service_area_name and service_area_town_names are not provided' do + subject.import_string single_record_with_service_area_counties + resource = CommunityResource.last + expect(resource.service_area.name).to eq "Queens County, Brooklyn" end + + it 'sets the service area location county' do + subject.import_string single_record_with_service_area_counties + resource = CommunityResource.last + + expect(resource.service_area.location.county).to eq "Queens County, Brooklyn" + end + + it 'sets the service area type to county' do + subject.import_string single_record_with_service_area_counties + resource = CommunityResource.last + + expect(resource.service_area.service_area_type).to eq "county" + end + end end end \ No newline at end of file From 1289da6f9bc895858261bd25089eb4f26b1ea5df Mon Sep 17 00:00:00 2001 From: senadakadric Date: Sat, 12 Sep 2020 16:44:44 -0400 Subject: [PATCH 5/9] created a new context to test for situations with multiple records --- .../community_resource_importer_spec.rb | 46 +++++++++++++------ 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb index ba2bf1aab..2d691c51c 100644 --- a/spec/models/importers/community_resource_importer_spec.rb +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -221,26 +221,44 @@ CSV } - it 'sets the service area name from the service_area_counties if service_area_name and service_area_town_names are not provided' do - subject.import_string single_record_with_service_area_counties - resource = CommunityResource.last + it 'sets the service area name from the service_area_counties if service_area_name and service_area_town_names are not provided' do + subject.import_string single_record_with_service_area_counties + resource = CommunityResource.last - expect(resource.service_area.name).to eq "Queens County, Brooklyn" - end + expect(resource.service_area.name).to eq "Queens County, Brooklyn" + end - it 'sets the service area location county' do - subject.import_string single_record_with_service_area_counties - resource = CommunityResource.last + it 'sets the service area location county' do + subject.import_string single_record_with_service_area_counties + resource = CommunityResource.last - expect(resource.service_area.location.county).to eq "Queens County, Brooklyn" - end + expect(resource.service_area.location.county).to eq "Queens County, Brooklyn" + end - it 'sets the service area type to county' do - subject.import_string single_record_with_service_area_counties - resource = CommunityResource.last + it 'sets the service area type to county' do + subject.import_string single_record_with_service_area_counties + resource = CommunityResource.last - expect(resource.service_area.service_area_type).to eq "county" + expect(resource.service_area.service_area_type).to eq "county" + end end end + + context 'with multiple records for a community resource' do + let(:multiple_records) { + <<~CSV + category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description + food,Food Vouchers,WIC,1340 State Route 9,Lake George,NY,12845,Warren,,,,518-761-6425,https://www.warrencountyny.gov/wic/,https://www.facebook.com/Warren-County-New-York-113824060252510/,2020-08-10,,TRUE,TRUE,,'WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday. Call to verify hours.' + food,Food Vouchers,WIC,383 Broadway,Fort Edward,NY,12828,Washington,,,,518-746-2460,https://washingtoncountyny.gov/179/WIC-Program,https://www.facebook.com/washingtoncountynywic/,2020-08-10,,TRUE,TRUE,,'WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday from 8:30 a.m. to 4:30 p.m.' + food,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,'Offers emergency food assistance. Families regardless of residency with limited food resources are invited to visit the Glens Falls Neighborhood Opportunity Center weekly to access food available. Open Monday through Friday from 8 a.m to 4:30 p.m.' + clothing,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,'Families regardless of residency with limited resources are invited to visit weekly to access the available free clothing. Open Monday through Friday 8 a.m. to 4:30 p.m.' + CSV + } + + it 'creates a three CommunityResources in the database' do + expect { + subject.import_string multiple_records + }.to change { CommunityResource.count }.from(0).to(3) + end end end \ No newline at end of file From 016de1826b41fd6eb4930ef62f0b1f8b7f90a57e Mon Sep 17 00:00:00 2001 From: Keith Walters Date: Sun, 13 Sep 2020 11:40:19 -0400 Subject: [PATCH 6/9] Avoid duplicating records when importing community resources When importing CommunityResource records, some rows in the dataset will have repeating Organization or Community Resource information. When this happens we want to re-use the existing objects in the database and update them accordingly. Specifically, instead of duplicating a CommunityResource the importer will update it to include the new tag and description. --- .../importers/community_resource_importer.rb | 69 ++++++++++++++--- .../community_resource_importer_spec.rb | 77 ++++++++++++++++++- 2 files changed, 134 insertions(+), 12 deletions(-) diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb index cfdfba91c..bbe3155d6 100644 --- a/app/models/importers/community_resource_importer.rb +++ b/app/models/importers/community_resource_importer.rb @@ -4,14 +4,65 @@ def primary_import_klass_name end def process_row(row) - puts "Pair programming @ RFG!!!" - comm_resource = CommunityResource.create! name: row["name"], website_url: row["website_url"], facebook_url: row["facebook_url"], phone: row["phone"], description: row["description"], youtube_identifier: row["youtube_identifier"], publish_from: row["publish_from"], publish_until: row["publish_until"], is_created_by_admin: row["is_created_by_admin"], is_approved: row["is_approved"] + puts "DEBUG::KGW -- processing org #{row["organization_name"]}" + organization = Organization.joins(:location).includes(:location) + .where(name: row["organization_name"]) + .where(locations: { + street_address: row["street"], + city: row["city"], + zip: row["zip"] + }).take - comm_resource.tag_list.add(row["category_name"]) - - comm_resource.organization = Organization.create! name: row["organization_name"] business_location = LocationType.find_or_create_by(name: "business") - comm_resource.location = Location.create! do |location| + + unless organization + organization = Organization.create! name: row["organization_name"] do |organization| + organization.location = Location.create! do |location| + location.street_address = row["street"] + location.city = row["city"] + location.state = row["state"] + location.zip = row["zip"] + location.county = row["county"] + location.location_type = business_location + end + end + end + + # Have to filter resources in memory because mobility prevents the + # `name` attribute from being persisted to the `community_resources` + # table. This prevents us from querying CommunityResource records by + # their name using ActiveRecord. + resource = organization.community_resources.detect { |resource| resource.name == row["name"] } + if resource + # Add breaks after the description so that if we are updating this resource with other row data there are visible + # gaps between each description entry + resource.description += "#{row["description"]}\n\n" + resource.tag_list.add(row["category_name"]) + + resource.save + + # Resource exists so there's nothing else to update. Return early and move onto the new row. + # This assumes nothing else needs to be updated for existing data. + return + end + + resource = CommunityResource.create!( + name: row["name"], + website_url: row["website_url"], + facebook_url: row["facebook_url"], + phone: row["phone"], + youtube_identifier: row["youtube_identifier"], + publish_from: row["publish_from"], + publish_until: row["publish_until"], + is_created_by_admin: row["is_created_by_admin"], + is_approved: row["is_approved"], + description: row["description"], + organization: organization + ) + + resource.tag_list.add(row["category_name"]) + + resource.location = Location.create! do |location| location.street_address = row["street"] location.city = row["city"] location.state = row["state"] @@ -21,7 +72,7 @@ def process_row(row) end service_location_type = LocationType.find_or_create_by(name: "service_area") - comm_resource.service_area = ServiceArea.create! do |service_area| + resource.service_area = ServiceArea.create! do |service_area| if row["service_area_name"] service_area.name = row["service_area_name"] elsif row["service_area_town_names"] @@ -38,7 +89,7 @@ def process_row(row) service_area.service_area_type = "city" end - service_area.organization = comm_resource.organization + service_area.organization = resource.organization service_area.location = Location.create! do |location| location.location_type = service_location_type @@ -50,6 +101,6 @@ def process_row(row) end end - comm_resource.save + resource.save end end \ No newline at end of file diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb index 2d691c51c..7f43adb17 100644 --- a/spec/models/importers/community_resource_importer_spec.rb +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -62,6 +62,42 @@ expect(resource.organization.name).to eq "WIC" end + it 'sets the location street on the CommunityResource Organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.location.street_address).to eq "123 Main Street" + end + + it 'sets the location city on the CommunityResource Organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.location.city).to eq "Springfield" + end + + it 'sets the location state on the CommunityResource Organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.location.state).to eq "XY" + end + + it 'sets the location zip on the CommunityResource Organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.location.zip).to eq "12345" + end + + it 'sets the location county on the CommunityResource Organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.location.county).to eq "Queens County" + end + + it 'sets the location type on the CommunityResource Organization' do + subject.import_string single_record + resource = CommunityResource.last + expect(resource.organization.location.location_type.name).to eq "business" + end + it 'creates a CommunityResource with a business location type' do subject.import_string single_record resource = CommunityResource.last @@ -252,13 +288,48 @@ food,Food Vouchers,WIC,383 Broadway,Fort Edward,NY,12828,Washington,,,,518-746-2460,https://washingtoncountyny.gov/179/WIC-Program,https://www.facebook.com/washingtoncountynywic/,2020-08-10,,TRUE,TRUE,,'WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday from 8:30 a.m. to 4:30 p.m.' food,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,'Offers emergency food assistance. Families regardless of residency with limited food resources are invited to visit the Glens Falls Neighborhood Opportunity Center weekly to access food available. Open Monday through Friday from 8 a.m to 4:30 p.m.' clothing,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,'Families regardless of residency with limited resources are invited to visit weekly to access the available free clothing. Open Monday through Friday 8 a.m. to 4:30 p.m.' - CSV - } + CSV + } - it 'creates a three CommunityResources in the database' do + it 'creates a three CommunityResources in the database' do expect { subject.import_string multiple_records }.to change { CommunityResource.count }.from(0).to(3) end + + it 'is not making sense' do + subject.import_string multiple_records + resources = CommunityResource.all + puts "DEBUG::KGW -- found #{resources.count} community resources" + resources.each do |resource| + puts " -> Resource: #{resource.inspect}" + end + end + + it 'creates two WIC organizations' do + subject.import_string multiple_records + organizations = Organization.where name: "WIC" + expect(organizations.count).to eq 2 + end + + it 'creates one Warren-Hamilton Counties Action Agency organization' do + subject.import_string multiple_records + organizations = Organization.where name: "Warren-Hamilton Counties Community Action Agency" + expect(organizations.count).to eq 1 + end + + it 'creates a Neighborhood Opportunity Center community resource' do + subject.import_string multiple_records + organization = Organization.find_by name: "Warren-Hamilton Counties Community Action Agency" + resources = organization.community_resources.select { |resource| resource.name == "Neighborhood Opportunity Center" } + expect(resources.count).to eq 1 + end + + it 'adds all of the tags to the record' do + subject.import_string multiple_records + organization = Organization.find_by name: "Warren-Hamilton Counties Community Action Agency" + resource = organization.community_resources.detect { |resource| resource.name == "Neighborhood Opportunity Center" } + expect(resource.tag_list).to eq %w(food clothing) + end end end \ No newline at end of file From 09ec7025833ffa791dd0aa56c91b3cd884c88c57 Mon Sep 17 00:00:00 2001 From: senadakadric Date: Sun, 13 Sep 2020 12:20:32 -0400 Subject: [PATCH 7/9] 44 tests created- most recently making sure the descriptions of comm resources were concatenated properly. tests passing. created a rake task to import the community resources. downloaded the csv from the spreadsheet and added it into the db/seeds/public_template_csvs. when running the rake task got 'validation failed: name cannot be blank' and the community resources were not created. need to explore what is occurring with that error --- .../importers/community_resource_importer.rb | 3 +- db/scripts/community_resource_seeds.rb | 8 ++ .../community_resources.csv | 89 +++++++++++++++++++ lib/tasks/db.rake | 4 + .../community_resource_importer_spec.rb | 8 ++ 5 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 db/scripts/community_resource_seeds.rb create mode 100644 db/seeds/public_template_csvs/community_resources.csv diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb index bbe3155d6..09df88b33 100644 --- a/app/models/importers/community_resource_importer.rb +++ b/app/models/importers/community_resource_importer.rb @@ -4,7 +4,6 @@ def primary_import_klass_name end def process_row(row) - puts "DEBUG::KGW -- processing org #{row["organization_name"]}" organization = Organization.joins(:location).includes(:location) .where(name: row["organization_name"]) .where(locations: { @@ -36,7 +35,7 @@ def process_row(row) if resource # Add breaks after the description so that if we are updating this resource with other row data there are visible # gaps between each description entry - resource.description += "#{row["description"]}\n\n" + resource.description += "\n\n#{row["description"]}" resource.tag_list.add(row["category_name"]) resource.save diff --git a/db/scripts/community_resource_seeds.rb b/db/scripts/community_resource_seeds.rb new file mode 100644 index 000000000..ef3bc53e7 --- /dev/null +++ b/db/scripts/community_resource_seeds.rb @@ -0,0 +1,8 @@ +require 'csv' + +csv = "community_resources.csv" +path = Rails.root.join('db', 'seeds', 'public_template_csvs', csv) +importer = Importers::CommunityResourceImporter.new(User.first) +importer.import(path) + +puts "completed community_resources.csv" diff --git a/db/seeds/public_template_csvs/community_resources.csv b/db/seeds/public_template_csvs/community_resources.csv new file mode 100644 index 000000000..896e5f2df --- /dev/null +++ b/db/seeds/public_template_csvs/community_resources.csv @@ -0,0 +1,89 @@ +category_name,name,organizaton_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description +food,Food Vouchers,WIC,1340 State Route 9,Lake George,NY ,12845,Warren,,,,518-761-6425,https://www.warrencountyny.gov/wic/,https://www.facebook.com/Warren-County-New-York-113824060252510/,2020-08-10,,TRUE,TRUE,,"WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday. Call to verify hours. " +food,Food Vouchers,WIC,383 Broadway,Fort Edward,NY ,12828,Washington,,,,518-746-2460,https://washingtoncountyny.gov/179/WIC-Program,https://www.facebook.com/washingtoncountynywic/,2020-08-10,,TRUE,TRUE,,"WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday from 8:30 a.m. to 4:30 p.m." +food,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,Offers emergency food assistance. Families regardless of residency with limited food resources are invited to visit the Glens Falls Neighborhood Opportunity Center weekly to access food available. Open Monday through Friday from 8 a.m to 4:30 p.m. +clothing,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY ,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,Families regardless of residency with limited resources are invited to visit weekly to access the available free clothing. Open Monday through Friday 8 a.m. to 4:30 p.m. +household items,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,Families regardless of residency with limited resources are invited to visit weekly to access the available free household items. Open Monday through Friday from 8 a.m. to 4:30 p.m. +case management,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,"Offers case management to address issues of education, employment or family functioning. Open Monday through Friday from 8 a.m. to 4:30 p.m." +rent,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street ,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,"Offers assistance to families in crisis, when funds are available. Payments made to prevent eviction. Open Monday through Friday from 8 a.m. to 4:30 p.m." +utilities ,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street ,Glens Falls ,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,"Offers assistance to families in crisis, when funds are available. Payments made to prevent utilities termination. Also, offers furnace testing, repair or replacement, insulation, caulking, weather-stripping and other energy conservation and/or housing repair measures. Residents must be income eligible but do not need to own the home. Open Monday through Friday from 8 a.m. to 4:30 p.m." +food,Food Pantry,Family Service Association of Glens Falls,150 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-0797,https://www.fsaglensfalls.org/,https://www.facebook.com/www.familyserviceassoc.org/,2020-08-10,,TRUE,TRUE,,Offers food to those in crisis or facing food insecurity by providing three days of food for each person in an eligible family. Open Monday through Thursday 9 a.m. to 3 p.m. +clothing,Feet First Program,Family Service Association of Glens Falls,150 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-0797,https://www.fsaglensfalls.org/,https://www.facebook.com/www.familyserviceassoc.org/,2020-08-10,,TRUE,TRUE,,Feet First helps provide eligible children with new shoes for the school year. Applications will be done on the phone from 8/10-8/13 starting at 9 a.m. Appointments for pick-up will be made between 8/17-8/21. Open Monday through Friday from 8:30 a.m. to 4:30 p.m. +case management,Advocacy,Family Service Association of Glens Falls,150 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-0797,https://www.fsaglensfalls.org/,https://www.facebook.com/www.familyserviceassoc.org/,2020-08-10,,TRUE,TRUE,,Offers casework for referrals and networking with other community agencies. Open Monday through Friday from 8:30 a.m. to 4:30 p.m +baby ,Infant Needs Program,Family Service Association of Glens Falls,150 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-0797,https://www.fsaglensfalls.org/,https://www.facebook.com/www.familyserviceassoc.org/,2020-08-10,,TRUE,TRUE,,"Provides supplies for newborns and their mothers who need help with diapers, formula and food. Open Monday through Friday from 8:30 a.m. to 4:30 p.m." +medical,Screening for Vision and Hearing,Family Service Association of Glens Falls,150 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-0797,https://www.fsaglensfalls.org/,https://www.facebook.com/www.familyserviceassoc.org/,2020-08-10,,TRUE,TRUE,,Provides glasses and hearing aids eligibility screenings. Open Monday through Friday 8:30 a.m. to 4:30 p.m. +medical,Emergency Prescription Program,Family Service Association of Glens Falls,150 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-0797,https://www.fsaglensfalls.org/,https://www.facebook.com/www.familyserviceassoc.org/,2020-08-10,,TRUE,TRUE,,Provides assistance in filling emergency RX. Open Monday through Friday 8:30 a.m. to 4:30 p.m. +shelter,Domestic Violence Project,"Catholic Charities of Saratoga, Warren & Washington Counties",35 Broad Street,Glens Falls ,NY,12801,,,"Warren, Washington, Saratoga",,518-793-6212,http://www.ccrcda.org/agencies_and_programs/Saratoga-Warren-Washington-Counties_109_2_sb.htm,https://www.facebook.com/ccrcda/,2020-08-10,,TRUE,TRUE,,Provides a 24-hour domestic violence hotline (518-793-9496) and emergency shelter. +shelter,Emergency Shelter,Wait House,10-12 Wait Street,Glens Falls,NY,12801,,,"Warren, Washington",,518-798-4384,https://hycwaithouse.org/,https://www.facebook.com/waithouseglensfalls/,2020-08-10,,TRUE,TRUE,,"Offers 30-day emergency shelter for homeless youth, transitional living for young women, and permanent housing assistance. Open 24/7. " +case management,Advocacy,Wait House,10-12 Wait Street,Glens Falls,NY,12801,,,"Warren, Washington",,518-798-4384,https://hycwaithouse.org/,https://www.facebook.com/waithouseglensfalls/,2020-08-10,,TRUE,TRUE,,"Offers assessment, case management, referrals, and crisis stabilization to youth who are homeless, at risk of homelessness, trafficked, or at risk of trafficking. Open 24/7" +food,Food Pantry,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,Offers a food pantry based on need. The amount of food varies by family size. Open by appointment only. +food,Soup Kitchen,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,Offers hot meals on Tuesdays at 5 p.m. +shelter,Emergency Shelter,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,"Offers emergency, family, women's, and transitional housing. Open Monday through Friday from 9 a.m. to 4 p.m., Monday evenings from 6 - 8 p.m., Tuesday evenings from 5 - 8 p.m., Thursday evenings from 4:30 - 8 p.m., and Sundays 9:30 a.m. to 1 p.m." +rent,Rent Assistance,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,"Offers rent assistance to help struggling families and individuals make ends meet. Open Monday through Friday from 9 a.m. to 4 p.m., Monday evenings from 6 - 8 p.m., Tuesday evenings from 5 - 8 p.m., Thursday evenings from 4:30 - 8 p.m., and Sundays 9:30 a.m. to 1 p.m." +utilities ,Utilities Assistance,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,"Offers utilities assistance to help struggling families and individuals make ends meet. Open Monday through Friday from 9 a.m. to 4 p.m., Monday evenings from 6 - 8 p.m., Tuesday evenings from 5 - 8 p.m., Thursday evenings from 4:30 - 8 p.m., and Sundays 9:30 a.m. to 1 p.m." +case management,Children's Care Management,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,"Provides help to families by making sure children get appointments with doctors, dentists, mental health providers or specialists. +Available to help whenever needed, 24/7. Open Monday through Friday from 9 a.m. to 4 p.m., Monday evenings from 6 - 8 p.m., Tuesday evenings from 5 - 8 p.m., Thursday evenings from 4:30 - 8 p.m., and Sundays 9:30 a.m. to 1 p.m." +medical,Children's Care Management,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,"Provides help to families by making sure children get appointments with doctors, dentists, mental health providers or specialists. +Available to help whenever needed, 24/7. Open Monday through Friday from 9 a.m. to 4 p.m., Monday evenings from 6 - 8 p.m., Tuesday evenings from 5 - 8 p.m., Thursday evenings from 4:30 - 8 p.m., and Sundays 9:30 a.m. to 1 p.m." +clothing,Emergency Clothing,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,Offers emergency clothing items for those facing a crisis. Open Monday through Friday from 9a.m. to 4 p.m. +household items,Emergency Household Items,Salvation Army of Glens Falls,37 Broad Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-1960,https://empire.salvationarmy.org/EmpireNY/Home,https://www.facebook.com/TheSalvationArmyGlensFalls/,2020-08-10,,TRUE,TRUE,,Offers emergency household items for those facing a crisis. Open Monday through Friday from 9 a.m. to 4 p.m. +medical,Advocacy,Southern Adirondack Independent Living (SAIL),71 Glenwood Avenue,Queensbury,NY,12804,,,"Warren, Washington",,518-792-3537,https://sailhelps.org/,https://www.facebook.com/SAIL.HELPS/,2020-08-10,,TRUE,TRUE,,"Offers health insurance guidance, medical equipment loans, and help accessing programs and services for people with disabilities. Open Monday through Friday from 8 a.m. to 4 p.m." +utilities ,Warren County DSS,Home Energy Assistance Program,1340 State Route 9,Lake George,NY,12845,Warren,,,,518-761-6338,https://www.warrencountyny.gov/socserv/,https://www.facebook.com/Warren-County-New-York-113824060252510/,2020-08-10,,TRUE,TRUE,,HEAP is a federally funded program designed to assist low income households meet heating related energy needs during the winter months. Open Monday through Friday 8 a.m. to 5 p.m. +utilities ,Utilities Assistance,LEAP Emergency Services,383 Broadway ,Fort Edward,NY,12828,Washington,,,,518-746-2390,https://www.leapservices.org/about/,https://www.facebook.com/LeapServices/,2020-08-10,,TRUE,TRUE,,Offers individuals and families with emergency payments to avoid shut offs of utilities. Open Monday through Friday from 8 a.m. to 4 p.m. +food,Food Pantry,LEAP Emergency Services,383 Broadway ,Fort Edward,NY,12828,Washington,,,,518-746-2390,https://www.leapservices.org/about/,https://www.facebook.com/LeapServices/,2020-08-10,,TRUE,TRUE,,Offers food once per month to residents in need. Open MWF 1:30 - 3:30 p.m. and TTH 9:30 - 11:30 a.m. +rent,Rent Assistance,LEAP Emergency Services,383 Broadway ,Fort Edward,NY,12828,Washington,,,,518-746-2390,https://www.leapservices.org/about/,https://www.facebook.com/LeapServices/,2020-08-10,,TRUE,TRUE,,Offers assistance once annually with first month's rent or emergency rent to avoid eviction. Open Monday through Friday from 8 a.m. to 4 p.m. +rent,Rent Assistance,Warren Country Department of Social Services,1340 State Route 9,Lake George,NY,12845,Warren,,,,518-761-6318,https://www.warrencountyny.gov/socserv/,https://www.facebook.com/Warren-County-New-York-113824060252510/,2020-08-10,,TRUE,TRUE,,Offers emergency assistance to familes and individuals with an immediate need such as eviction. Open Monday through Friday from 8 a.m. to 5 p.m. +rent,Rent Assistance,Washington County Department of Social Services,383 Broadway,Fort Edward ,NY,12828,Washington,,,,518-746-2300,https://www.washingtoncountyny.gov/517/Social-Services,https://www.facebook.com/Washington-County-Department-of-Social-Services-198945927130054/,2020-08-10,,TRUE,TRUE,,Offers temporary assistance for housing. A face-to-face interview is required for this program. Open Monday through Friday from 8:30 a.m. to 4:30 p.m. +food,Meal,Warren Country Office for the Aging,1340 State Route 9,Lake George,NY,12845,Warren,,,,518-761-6347,https://www.warrencountyny.gov/ofa/,https://www.facebook.com/WarrenHamilton-Counties-Office-for-the-Aging-355874641489639/,2020-08-10,,TRUE,TRUE,,"Offers meals Monday through Friday to any person 60 years of age or older, regardless of income level or resources. A voluntary contribution of $3 is suggested. Individuals under 60 years of age are welcome as well, but are required to contribute $5. Meal sites are located throughout Warren County. Bolton Landing: Church of St. Sacrament at 4879 Lake Shore Dr. - Chestertown: Town Hall at 6307 State Route 9 - Glens Falls: First Presbyterian Church at 400 Glen St. - Johnsburg: Senior Center at 3548 State Route 28 - Lake Luzerne: Senior Center at 539 Lake Ave. - Queensbury: Cedars Senior Living at 35 Evergreen Ln. and Solomon Heights at 18 Farr East Ln. - Warrensburg: Countryside Adult Home at 353 Schroon River Rd. " +food,Food Pantry,Sacred Heart Food Pantry,50 Mohican Street,Lake George,NY,12845,Warren,,,,518-668-2046,http://www.sacredheartlg.org/,https://www.facebook.com/sacredheartlg.catholic/,2020-08-10,,TRUE,TRUE,,Food pantry is open the 2nd and/or 4th Friday of each month from 1 - 3 p.m. Contact Kathy Dorman at kathy.dorman4@gmail.com. +food,Meal,Sacred Heart Catholic Church,50 Mohican Street,Lake George,NY,12845,Warren,,,,518-668-2046,http://www.sacredheartlg.org/,https://www.facebook.com/sacredheartlg.catholic/,2020-08-10,,TRUE,TRUE,,Community dinners October through May on Wednesdays from 5 - 6 p.m. Contact Kathy Dorman at kathy.dorman4@gmail.com. +food,Meal,Christ Church United Methodist ,54 Bay Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-793-3468,https://christchurchglensfalls.org/,,2020-08-10,,TRUE,TRUE,,"Community dinners offered on the last Saturday of the month. Church office hours are Monday, Tuesday, Thursday from 9 a.m. to 3:30 p.m." +food,Meal,Faith Tabernacle Baptist Church ,12 Nelson Street,Glens Falls,NY,12801,Warren,Glens Falls,,,518-798-5054,,https://www.facebook.com/faithtabernaclemissionarybaptistchurch/,2020-08-10,,TRUE,TRUE,,Community dinners offered on the first Friday of the month. +food,Meal,Church of the Messiah,296 Glen Street,Glens Falls,NY,12801,Warren,Glens Falls,,,518-792-1560,https://www.messiahgf.org/,https://www.facebook.com/messiahglensfalls/,2020-08-10,,TRUE,TRUE,,Community dinners offered Sundays at 5:30 p.m. but temporarily canceled due to COVID-19. +clothing,Good Shepherd Clothes Closet,Church of the Messiah,296 Glen Street,Glens Falls,NY,12801,Warren,Glens Falls,,,518-792-1560,https://www.messiahgf.org/,https://www.facebook.com/messiahglensfalls/,2020-08-10,,TRUE,TRUE,,Temoprarily closed due to COVID-19. +food,Food Pantry,Church of the Messiah,296 Glen Street,Glens Falls,NY,12801,Warren,Glens Falls,,,518-792-1560,https://www.messiahgf.org/,https://www.facebook.com/messiahglensfalls/,2020-08-10,,TRUE,TRUE,,Temoprarily closed due to COVID-19. +food,Food Pantry,St. Mary's Church Food Pantry,62 Warren Street,Glens Falls,NY,12801,Warren,,,"Glens Falls, Queensbury",518-792-0989,https://www.stmarysglensfalls.org/food-pantry,https://www.facebook.com/StMarysGlensFalls/,2020-08-10,,TRUE,TRUE,,Clients can use the pantry twice per month. Photo ID is required. Open Fridays from 9 a.m. to 1 p.m. +food,Bread of Life Food Pantry,Calvary's Family Life Center ,100 Sherman Avenue,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-798-0850,https://www.agcalvary.com/ministries,https://www.facebook.com/CalvarysFamilyLifeCenter/,2020-08-10,,TRUE,TRUE,,Open Tuesdays 10 a.m. to 1 p.m. & 5 p.m. to 6:30 p.m. +food,Food Pantry,Queensbury United Methodist Church,460 Aviation Road,Queensbury,NY,12804,Warren,,,"Glens Falls, Queensbury, Lake George",518-793-9728,https://umcq.org/food-pantry/,https://www.facebook.com/queensburyumc/,2020-08-10,,TRUE,TRUE,,"Proof of residency is required. Bring shopping bags and visit only once every four weeks. Closed the first week of the month. Open Tuesdays from 9:30 to11 a.m. Thursday and Saturday hours vary, so check webiste or call. " +food,Bread of Life Food Pantry,Zion Episcopal Church,224 Main Street,Hudson Falls,NY,12839,Washington,,,,518-747-6514,https://episcopalchurch.org/parish/zion-episcopal-church-hudson-falls-ny,https://www.facebook.com/ZionEpiscopalChurch/,2020-08-10,,TRUE,TRUE,,Open Wednesdays noon to 3 p.m. and Saturdays 10 a.m. to 2 p.m. +clothing,Zion's Closet,Zion Episcopal Church,224 Main Street,Hudson Falls,NY,12839,Washington,,,,518-747-6514,https://episcopalchurch.org/parish/zion-episcopal-church-hudson-falls-ny,https://www.facebook.com/ZionEpiscopalChurch/,2020-08-10,,TRUE,TRUE,,Open Wednesdays noon to 3 p.m. and Saturdays 10 a.m. to 2 p.m. +food,Soup Kitchen,Open Door Misson,47 Lawrence Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-5900,https://opendoor-ny.org/,https://www.facebook.com/OpenDoorNY/,2020-08-10,,TRUE,TRUE,,"Breakfast is served Monday through Friday from 8 to 9:30 a.m. Lunch is served Monday through Saturday 11:30 a.m. to 12:30 p.m. Dinner is served Monday, Wednesday, Thursday, Friday (except the first Friday of the month) from 4:30 to 5:30 p.m." +food,Food Pantry,Open Door Misson,226 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-5900,https://opendoor-ny.org/,https://www.facebook.com/OpenDoorNY/,2020-08-10,,TRUE,TRUE,,Offers emergency food assistance only. Open Monday Thursday from 1 to 4 p.m. +shelter,Emergency Shelter,Open Door Misson,226 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-5900,https://opendoor-ny.org/,https://www.facebook.com/OpenDoorNY/,2020-08-10,,TRUE,TRUE,,"Offers beds to men experiencing homelessness. Also offers a Day Room daily from 9 to 11 a.m. & 1 to 4 p.m. for those experiencing homelessness to come in off the streets, do laundry and access computers. From November to March offers overnight shelter when temperature drops below 32 degrees or 12"" or more of snow is in the immediate forecast." +case management,Advocacy,Open Door Misson,226 Warren Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-792-5900,https://opendoor-ny.org/,https://www.facebook.com/OpenDoorNY/,2020-08-10,,TRUE,TRUE,,"Services include encouragement for daily living, counseling, connections to community resources, medical screenings, substance abuse recovery programs, budgeting, transportation, life and job skills. Open Monday through Friday from 9 a.m. to 5 p.m." +medical,Health Care Management,Adirondack Health Institute,101 Ridge Street,Glens Falls,NY,12801,,,"Warren, Washington, Saratoga",,518-480-0111,https://ahihealth.org/,https://www.facebook.com/ahihealth/,2020-08-10,,TRUE,TRUE,,"Offers help with health insurance. Coordinates medical and behavioral health care for those with HIV/AIDS, a serious and persistent mental illness, or two or more other chronic conditions." +rent,Rent Assistance,Glens Falls Housing Authority/Public Housing/Section 8,23 Jay Street,Glens Falls,NY,12801,Warren,Glens Falls,,,518-793-2583,http://www.glensfallshousingauthority.org/,,2020-08-10,,TRUE,TRUE,,Provides rental assistance to homeless or low income individuals or families. +food,Food Pantry,Moreau Community Center,144 Main Street,South Glens Falls,NY,12803,Saratoga,South Glens Falls,,,518-792-6007,https://moreaucommunitycenter.org/,https://www.facebook.com/MoreauCommunityCenter/,2020-08-10,,TRUE,TRUE,,Serves residents of the South Glens Falls school district. Households may utilize the food pantry once per month. Each month bring valid photo ID and a piece of mail for each resident of the household over the age of 18. Open Monday through Friday from 9 a.m. to 2:45 p.m. No appointment necessary. +food,Food Pantry,Pine Knolls Alliance Church,614 Gansevoort Road,South Glens Falls,NY,12803,,,"Warren, Washington, Saratoga",,518-793-7107,http://pineknolls.net/home,https://www.facebook.com/groups/pineknolls/,2020-08-10,,TRUE,TRUE,,Open Saturday from 9 to 10:30 a.m. and Sunday by appointment only. +food,Food Pantry,Lake George Food Pantry at Caldwell Presbyterian Church,71 Montcalm Street,Lake George,NY,12845,Warren,,,"Queensbury, Lake George",518-668-2613,http://www.caldwellpres.org/,https://www.facebook.com/pages/Caldwell-Presbyterian-Church/115878831775425,2020-08-10,,TRUE,TRUE,,Open 2nd and 4th Fridays of each month from 10 a.m. to noon. +food,Food Pantry,Maxfield Community Food Pantry,89 Bay Road ,Lake Luzerne,NY,12846,,,"Warren, Saratoga","Lake Luzerne, Hadley",518-696-4979,,https://www.facebook.com/Maxfieldcommunityfoodpantry/,2020-08-10,,TRUE,TRUE,,"Offers emergency food assistance to residents of the Hadley Luzern School District. Open 5 days a week. Open MWF from 1 to 4 p.m., Tuesday from 6 to 8 p.m., Thursday from 9 a.m. to noon. Check Facebook page or call for an appointment." +food,Food Pantry,Corinth Community Cupboard Food Pantry,6 Fourth Street,Corinth,NY,12822,Saratoga,Corinth,,,518-769-2067,,https://www.facebook.com/CorinthNYFoodPantry/,2020-08-10,,TRUE,TRUE,,"Offers 3 days of emergency food to residents of the Corinth School District. Open Tuesday & Friday from 2 to 5 p.m., Wednesday from 6 to 8 p.m., Thursday & Saturday from 9 a.m. to noon. Check Facebook page or call for an appointment." +food,Food Pantry,First Presbyterian Church of Warrensburg Food Pantry,2 Stewart Farrar Street,Warrensburg,NY,12885,Warren,Warrensburg,,,518-623-2723,,https://www.facebook.com/FirstPresbyterianChurchOfWarrensburg/,2020-08-10,,TRUE,TRUE,,Open Monday from 9 a.m. to noon. +food,Food Pantry,North Country Ministry Food Pantry,3933 Main Street,Warrensburg,NY,12885,Warren,,,"Warrensburg, Pottersville, North Creek, Johnsburg, Brant Lake, Chester, Horicon",518-623-2829,http://www.northcountryministry.org/,https://www.facebook.com/NCMHope/,2020-08-10,,TRUE,TRUE,,Open at the Warrensburg Center on Wednesday from 1 to 4 p.m. Open at the YMCA Adirondack Center at 148 Tannery Road in Brant Lake on Wednesday from 3 to 5 p.m. +clothing,Clothing Center,North Country Ministry Food Pantry,3933 Main Street,Warrensburg,NY,12885,Warren,,,"Warrensburg, Pottersville, North Creek, Johnsburg, Brant Lake, Chester, Horicon",518-623-2829,http://www.northcountryministry.org/,https://www.facebook.com/NCMHope/,2020-08-10,,TRUE,TRUE,,"Open by appointment only on Fridays. To schedule an appointment, contact Laurie Bartlett at 518.623.2829 Ext. 302 or adminassistant@northcountryministry.org." +case management,Advocacy,North Country Ministry Food Pantry,3933 Main Street,Warrensburg,NY,12885,Warren,,,"Warrensburg, Pottersville, North Creek, Johnsburg, Brant Lake, Chester, Horicon",518-623-2829,http://www.northcountryministry.org/,https://www.facebook.com/NCMHope/,2020-08-10,,TRUE,TRUE,,"Offers casework services at the Warrensburg location (3933 Main Street) and the North Creek location (32 Circle Drive, 518-251-4460)." +household items,Furniture Program,North Country Ministry Food Pantry,3933 Main Street,Warrensburg,NY,12885,Warren,,,"Warrensburg, Pottersville, North Creek, Johnsburg, Brant Lake, Chester, Horicon",518-623-2829,http://www.northcountryministry.org/,https://www.facebook.com/NCMHope/,2020-08-10,,TRUE,TRUE,,Call for information. +food,Food Pantry,Warrensburg Town Hall,3797 Main Street,Warrensburg,NY,12885,Warren,Warrensburg,,,518-623-4561,https://townofwarrensburg.org/index.html,https://www.facebook.com/pages/Town-of-Warrensburg-Town-Hall/556507611176367,2020-08-10,,TRUE,TRUE,,"Call the Town Clerk, Donna Combs, for more information." +food,Food Pantry,Chestertown Food Pantry,6307 Route 9,Chestertown,NY,12817,Warren,Chestertown,,,518-494-2433,https://www.townofchesterny.org/food-pantry.html,,2020-08-10,,TRUE,TRUE,,Call Amy Combs for more information. Open Monday through Friday from 10 a.m. to 3 p.m. +food,Food Pantry,Argyle Presbyterian Church Food Pantry,48 Main Street,Argyle,NY,12809,Washington,Argyle,,,518-638-8072,https://www.argylepresbyterian.org/,https://www.facebook.com/argyle.presbyterian/,2020-08-10,,TRUE,TRUE,,Offers food to residents of Argyle. Open Saturday 10 a.m. to noon. +clothing,Christ's Closet,Argyle United Methodist Church,12 Sheridan ,Argyle,NY,12809,Washington,Argyle,,,518-638-8955,https://www.unyumc.org/resources/church/argyle-umc,https://www.facebook.com/Christs-Closet-Thrift-Shop-1701660193415899/,2020-08-10,,TRUE,TRUE,,The thrift shop has no set prices. Everything is make a donation. Open Saturday 9 a.m. to noon and the first Friday of the month from 2 to 5 p.m. +household items,Christ's Closet,Argyle United Methodist Church,12 Sheridan ,Argyle,NY,12809,Washington,Argyle,,,518-638-8955,https://www.unyumc.org/resources/church/argyle-umc,https://www.facebook.com/Christs-Closet-Thrift-Shop-1701660193415899/,2020-08-10,,TRUE,TRUE,,The thrift shop has no set prices. Everything is make a donation. Open Saturday 9 a.m. to noon and the first Friday of the month from 2 to 5 p.m. +food,Food Pantry,Fort Edward Community Food Pantry at the Village Baptist Church,131 Broadway,Fort Edward,NY,12828,Washington,Fort Edward,,,518-747-5939,,https://www.facebook.com/fortedwardcommunityfoodpantry/,2020-08-10,,TRUE,TRUE,,"Provides groceries to those in need within the Town and Village of Fort Edward. Open Tuesday, Thursday and Saturday from 4 to 7 p.m. Call for an appointment." +food ,Food Pantry,Cornerstone Outreach Center Food Pantry,1767 State Route 196,Fort Edward,NY,12828,Washington,,,,518-747-6814,http://cornerstoneoutreachcenter.com/index.php/food-pantry-outreach/,https://www.facebook.com/CornerStone-Outreach-Center-361887220560345/,2020-08-10,,TRUE,TRUE,,Open Wednesday from noon to 3 p.m. +food,Food Pantry,Granville Area Food Pantry and Community Services,3 Morrison Avenue,Granville,NY,12832,Washington,Granville,,,518-642-1853,https://regionalfoodbank.net/agencies/mvec-food-pantry/,,2020-08-10,,TRUE,TRUE,,Serves residents of the Granville School District. Proof of residency required. Open Saturday 9 to 11:15 a.m. +food,Food Pantry,Comfort Food Community Center,2530 Route 40,Greenwich,NY,12834,Washington,Greenwich,,,518-538-3522,http://comfortfoodcommunity.org/,https://www.facebook.com/comfortfoodcommunity/,2020-08-10,,TRUE,TRUE,,"Serves residents of the Greenwich School District. Proof of residency required (ID, utility bill, etc.) for first visit. Guests are welcome to visit once a week. Greenwich pantry open Monday & Wednesday from 4 to 7 p.m. and Wednesday from 9 to 11 a.m. Cossayuna Pantry is located at 21 Bunkerhill Road and is open Tuesday from 3:30 to 5:30 p.m." +food,Food Pantry,Hartford Food Pantry,56 Main Street,Hartford,NY,12838,Washington,Hartford,,,518-632-5805,https://regionalfoodbank.net/agencies/hartford-food-pantry/,,2020-08-10,,TRUE,TRUE,,Serves the Town of Hartford. Proof of town residency required. Open every other Saturday from 9 to 10:30 a.m. Call for dates. +food,Food Pantry,Doreen's Food Pantry at the HF United Methodist Church,227 Main Street,Hudson Falls,NY,12839,Washington,Hudson Falls,,,518-747-9042,,https://www.facebook.com/doreenssoupkitchen/,2020-08-10,,TRUE,TRUE,,Open by appointment only. +food,Food Pantry,Salem Food Pantry,32 East Broadway,Salem,NY,12865,Washington,Salem,,,518-854-3317,,https://www.facebook.com/The-Salem-Food-Pantry-111076757252846/,2020-08-10,,TRUE,TRUE,,Serves residents of the Salem School District. Open Saturday from 9:30 to 11:30 a.m. Also open by appointment. +food,Food Pantry,Whitehall Community Food Pantry,56 Greenmount Cemetary Lane,Whitehall,NY,12887,Washington,,,"Whitehall, Clemons, Comstock",518-499-2039,,https://www.facebook.com/Whitehall-Community-Food-Pantry-156151074432785/,2020-08-10,,TRUE,TRUE,,Call for hours. +food,Food Pantry,Cambridge Food Pantry,59 South Park Street,Cambridge,NY,12816,Washington,Cambridge,,,518-677-7172,,https://www.facebook.com/CambridgeNYLoavesandfishes/,2020-08-10,,TRUE,TRUE,,"Open Wednesday from 1 to 3 p.m., Friday from 4 to 6 p.m., and Saturday from 11 a.m. to 1 p.m. " +food,Food Pantry,Christ's Cupboard Food Pantry at the First Baptist Church of Ballston Spa,202 Milton Avenue,Ballston Spa,NY,12020,Saratoga,,,,518-885-8361,http://bspabaptist.org/our-mission-field/food-pantry/,,2020-08-10,,TRUE,TRUE,,Must be a Saratoga County resident. Need government issued photo ID to use pantry. Limited to one visit per month. Open first and third Tuesdays of the month from 9 to 11 a.m. and Thursday from 4:30 to 6 p.m. +food ,Food Pantry,Saratoga County EOC Food Pantry,39 Bath Street,Ballston Spa,NY,12020,Saratoga,,,,518-228-3206,https://saratogaeoc.org/foodprograms/,https://www.facebook.com/sceoc/,2020-08-10,,TRUE,TRUE,,"Open Monday from 12:30 to 5 p.m., Tuesday from 9 a.m. to noon, Wednesday from 9 a.m. to 4 p.m., and Friday 12:30 to 4 p.m." +food ,Soup Kitchen,Saratoga County EOC Soup Kitchen at the Presbyterian New England Congretional Church,24 Circular Street,Saratoga,NY,12866,Saratoga,,,,518-581-8233,https://saratogaeoc.org/foodprograms/,https://www.facebook.com/sceoc/,2020-08-10,,TRUE,TRUE,,Lunch is served Monday through Saturday from 11:45 a.m. to 1 p.m. and Sunday from 3 to 4 p.m. +clothing,Dress for Work,Saratoga County EOC,39 Bath Street,Ballston Spa,NY,12020,Saratoga,,,,518-228-3206,https://saratogaeoc.org/programs/community-services/advocacy/,https://www.facebook.com/sceoc/,2020-08-10,,TRUE,TRUE,,Provides appropriate interview or work clothing to individuals in need. This is a collaboration between EOC and Treasures Consignment/Thrift store. Interested individuals need to come in and meet with a worker to obtain a voucher. +food,Karyl's Kupboard Emergency Food and Hygiene Pantry,CAPTAIN Community Human Services,5 Municipal Plaza Suite 3,Clifton Park,NY,12065,Saratoga,,,,518-371-1185,https://captaincares.org/what-we-do/emergency-assistance/food-pantry.html,https://www.facebook.com/CAPTAINCHS/,2020-08-10,,TRUE,TRUE,,"Open to any member of Saratoga County who is in need of food or hygiene products. Must bring photo ID and proof of Saratoga County residency. May be utilized once every 30 days. No appointments are necessary, and there is a simple application. Open Monday, Tuesday, and Thursday from 10 a.m. to 3 p.m." +hygiene,Karyl's Kupboard Emergency Food and Hygiene Pantry,CAPTAIN Community Human Services,5 Municipal Plaza Suite 3,Clifton Park,NY,12065,Saratoga,,,,518-371-1185,https://captaincares.org/what-we-do/emergency-assistance/food-pantry.html,https://www.facebook.com/CAPTAINCHS/,2020-08-10,,TRUE,TRUE,,"Open to any member of Saratoga County who is in need of food or hygiene products. Must bring photo ID and proof of Saratoga County residency. May be utilized once every 30 days. No appointments are necessary, and there is a simple application. Open Monday, Tuesday, and Thursday from 10 a.m. to 3 p.m." +shelter,Emergency Shelter,CAPTAIN Community Human Services,5 Municipal Plaza Suite 3,Clifton Park,NY,12065,Saratoga,,,,518-371-1185,https://captaincares.org/what-we-do/emergency-assistance/food-pantry.html,https://www.facebook.com/CAPTAINCHS/,2020-08-10,,TRUE,TRUE,,"Emergency rental or utility assistance is available to those residents of Saratoga County who have received a notice of eviction, are at imminent risk of losing their housing, are literally homeless, or are facing a utility shutoff." +utilities ,Utilities Assistance,CAPTAIN Community Human Services,5 Municipal Plaza Suite 3,Clifton Park,NY,12065,Saratoga,,,,518-371-1185,https://captaincares.org/what-we-do/emergency-assistance/food-pantry.html,https://www.facebook.com/CAPTAINCHS/,2020-08-10,,TRUE,TRUE,,"Emergency rental or utility assistance is available to those residents of Saratoga County who have received a notice of eviction, are at imminent risk of losing their housing, are literally homeless, or are facing a utility shutoff." +rent,Rent Assistance,CAPTAIN Community Human Services,5 Municipal Plaza Suite 3,Clifton Park,NY,12065,Saratoga,,,,518-371-1185,https://captaincares.org/what-we-do/emergency-assistance/food-pantry.html,https://www.facebook.com/CAPTAINCHS/,2020-08-10,,TRUE,TRUE,,"Emergency rental or utility assistance is available to those residents of Saratoga County who have received a notice of eviction, are at imminent risk of losing their housing, are literally homeless, or are facing a utility shutoff." +food,Food Pantry,St. Clement's Church Outreach,231 Lake Avenue,Saratoga,NY,12866,Saratoga,,,,518-9805,https://regionalfoodbank.net/agencies/st-clements-outreach/,https://www.facebook.com/St-Clements-Church-Saratoga-Springs-NY-224780885975/,2020-08-10,,TRUE,TRUE,,Open to Saratoga County residents. Proof of residency required. Open Tuesday & Wednesday from 9 a.m. to noon. \ No newline at end of file diff --git a/lib/tasks/db.rake b/lib/tasks/db.rake index d478cad11..8d9a3a677 100644 --- a/lib/tasks/db.rake +++ b/lib/tasks/db.rake @@ -52,6 +52,10 @@ namespace :db do task :import_custom_form_question_seeds => :environment do require "#{Rails.root}/db/scripts/custom_form_question_seeds.rb" end + + task :import_community_resource_seeds => :environment do + require "#{Rails.root}/db/scripts/community_resource_seeds.rb" + end end diff --git a/spec/models/importers/community_resource_importer_spec.rb b/spec/models/importers/community_resource_importer_spec.rb index 7f43adb17..9322dd635 100644 --- a/spec/models/importers/community_resource_importer_spec.rb +++ b/spec/models/importers/community_resource_importer_spec.rb @@ -331,5 +331,13 @@ resource = organization.community_resources.detect { |resource| resource.name == "Neighborhood Opportunity Center" } expect(resource.tag_list).to eq %w(food clothing) end + + it 'adds concats the descriptions to a record' do + subject.import_string multiple_records + organization = Organization.find_by name: "Warren-Hamilton Counties Community Action Agency" + resource = organization.community_resources.detect { |resource| resource.name == "Neighborhood Opportunity Center" } + + expect(resource.description).to eq "'Offers emergency food assistance. Families regardless of residency with limited food resources are invited to visit the Glens Falls Neighborhood Opportunity Center weekly to access food available. Open Monday through Friday from 8 a.m to 4:30 p.m.'\n\n'Families regardless of residency with limited resources are invited to visit weekly to access the available free clothing. Open Monday through Friday 8 a.m. to 4:30 p.m.'" + end end end \ No newline at end of file From 5429bf67f597d2c4757dadb3789faad57b772649 Mon Sep 17 00:00:00 2001 From: Svetlana Vileshina Date: Sat, 27 Mar 2021 11:05:09 -0400 Subject: [PATCH 8/9] typo in seed data Co-authored-by: maebeale Co-authored-by: connieh1 --- db/seeds/public_template_csvs/community_resources.csv | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/seeds/public_template_csvs/community_resources.csv b/db/seeds/public_template_csvs/community_resources.csv index 896e5f2df..689e25214 100644 --- a/db/seeds/public_template_csvs/community_resources.csv +++ b/db/seeds/public_template_csvs/community_resources.csv @@ -1,4 +1,4 @@ -category_name,name,organizaton_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description +category_name,name,organization_name,street,city,state,zip,county,service_area_name,service_area_counties,service_area_town_names,phone,website_url,facebook_url,publish_from,publish_until,is_created_by_admin,is_approved,youtube_identifier,description food,Food Vouchers,WIC,1340 State Route 9,Lake George,NY ,12845,Warren,,,,518-761-6425,https://www.warrencountyny.gov/wic/,https://www.facebook.com/Warren-County-New-York-113824060252510/,2020-08-10,,TRUE,TRUE,,"WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday. Call to verify hours. " food,Food Vouchers,WIC,383 Broadway,Fort Edward,NY ,12828,Washington,,,,518-746-2460,https://washingtoncountyny.gov/179/WIC-Program,https://www.facebook.com/washingtoncountynywic/,2020-08-10,,TRUE,TRUE,,"WIC offers food vouchers to moms, dads, foster parents, guardians, pregnant women, grandparents and step-parents who are income-eligible. Open Monday through Friday from 8:30 a.m. to 4:30 p.m." food,Neighborhood Opportunity Center,Warren-Hamilton Counties Community Action Agency,190 Maple Street,Glens Falls,NY,12801,Warren,,,,518-793-0636,http://wahacaa.org/,https://www.facebook.com/wahccaeo/,2020-08-10,,TRUE,TRUE,,Offers emergency food assistance. Families regardless of residency with limited food resources are invited to visit the Glens Falls Neighborhood Opportunity Center weekly to access food available. Open Monday through Friday from 8 a.m to 4:30 p.m. From 5cca2be11ca42b76cb9f84861b8b9c69679275a9 Mon Sep 17 00:00:00 2001 From: Connie Hyman Date: Sat, 3 Apr 2021 08:36:55 -0700 Subject: [PATCH 9/9] Rename variable, apply i18n, iterate category_name, and improve idempotentcy Co-authored-by: maebeale Co-authored-by: exbinary --- .../importers/community_resource_importer.rb | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/app/models/importers/community_resource_importer.rb b/app/models/importers/community_resource_importer.rb index 09df88b33..18e0b1f50 100644 --- a/app/models/importers/community_resource_importer.rb +++ b/app/models/importers/community_resource_importer.rb @@ -27,25 +27,22 @@ def process_row(row) end end - # Have to filter resources in memory because mobility prevents the - # `name` attribute from being persisted to the `community_resources` - # table. This prevents us from querying CommunityResource records by - # their name using ActiveRecord. - resource = organization.community_resources.detect { |resource| resource.name == row["name"] } - if resource - # Add breaks after the description so that if we are updating this resource with other row data there are visible - # gaps between each description entry - resource.description += "\n\n#{row["description"]}" - resource.tag_list.add(row["category_name"]) - - resource.save + community_resource = organization.community_resources.i18n.where(name: row["name"], publish_from: row["publish_from"]) + if community_resource + community_resource.description = row["description"] + + row["category_name"].split(/,\s*/).each do |category| + community_resource.tag_list << category + end + + community_resource.save # Resource exists so there's nothing else to update. Return early and move onto the new row. # This assumes nothing else needs to be updated for existing data. return end - resource = CommunityResource.create!( + community_resource = CommunityResource.create!( name: row["name"], website_url: row["website_url"], facebook_url: row["facebook_url"], @@ -59,9 +56,11 @@ def process_row(row) organization: organization ) - resource.tag_list.add(row["category_name"]) + row["category_name"].split(/,\s*/).each do |category| + community_resource.tag_list << category + end - resource.location = Location.create! do |location| + community_resource.location = Location.create! do |location| location.street_address = row["street"] location.city = row["city"] location.state = row["state"] @@ -71,7 +70,7 @@ def process_row(row) end service_location_type = LocationType.find_or_create_by(name: "service_area") - resource.service_area = ServiceArea.create! do |service_area| + community_resource.service_area = ServiceArea.create! do |service_area| if row["service_area_name"] service_area.name = row["service_area_name"] elsif row["service_area_town_names"] @@ -88,7 +87,7 @@ def process_row(row) service_area.service_area_type = "city" end - service_area.organization = resource.organization + service_area.organization = community_resource.organization service_area.location = Location.create! do |location| location.location_type = service_location_type @@ -100,6 +99,6 @@ def process_row(row) end end - resource.save + community_resource.save end end \ No newline at end of file