From 12aac05777d62735da51cd0631a0661afe5ed09e Mon Sep 17 00:00:00 2001 From: Jennifer Tilton Date: Fri, 3 Feb 2017 12:49:24 -0800 Subject: [PATCH] add a `commitment` field for how often a host plans to host --- app/models/city.rb | 2 +- .../20170203195548_add_commitment_to_host_details.rb | 9 +++++++++ db/schema.rb | 3 ++- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20170203195548_add_commitment_to_host_details.rb diff --git a/app/models/city.rb b/app/models/city.rb index 91742a79..5fd7a6a1 100644 --- a/app/models/city.rb +++ b/app/models/city.rb @@ -51,7 +51,7 @@ def pending_approval? def hosts User.hosts.where(home_city: [self] + proxy_cities) end - + def hosts_by_status users = User.hosts.where(home_city: self.id).includes(:host_detail).group_by {|h| h.host_detail.activity_status } # Return empty array if there are no users in that group diff --git a/db/migrate/20170203195548_add_commitment_to_host_details.rb b/db/migrate/20170203195548_add_commitment_to_host_details.rb new file mode 100644 index 00000000..ab199d38 --- /dev/null +++ b/db/migrate/20170203195548_add_commitment_to_host_details.rb @@ -0,0 +1,9 @@ +class AddCommitmentToHostDetails < ActiveRecord::Migration + def up + add_column :host_details, :commitment, :integer + end + + def down + remove_column :host_details, :commitment, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index af058cdc..04453d96 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20161001202222) do +ActiveRecord::Schema.define(version: 20170203195548) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -77,6 +77,7 @@ t.integer "activity_status", default: 0 t.datetime "created_at" t.datetime "updated_at" + t.integer "commitment" end create_table "proxy_cities", force: true do |t|