From cd9a71dead398dc800a178abae5456b9ddb1fe2b Mon Sep 17 00:00:00 2001 From: Mike Hall Date: Tue, 26 Aug 2014 00:38:35 -0500 Subject: [PATCH] Revert "Mongo grave " --- Gemfile | 4 - Gemfile.lock | 33 ---- app/jobs/refresh_user_job.rb | 5 + app/jobs/team_migrator_batch_job.rb | 10 -- app/jobs/team_migrator_job.rb | 169 ------------------ app/models/concerns/team_migration.rb | 24 --- app/models/concerns/team_search.rb | 8 - app/models/followed_team.rb | 7 +- app/models/pg_team.rb | 41 ++--- app/models/team.rb | 24 +-- app/models/teams/link.rb | 6 +- app/models/teams/location.rb | 15 +- app/models/teams/member.rb | 32 ++-- app/models/user.rb | 41 +++-- app/models/user_event.rb | 3 +- app/models/users/github/repository.rb | 5 +- app/uploaders/team_uploader.rb | 8 - config/initializers/elasticsearch.rb | 5 - config/initializers/tire.rb | 3 + .../20140823103534_add_migration_fields.rb | 7 - db/migrate/20140823174046_fix_pg_team.rb | 26 --- db/schema.rb | 67 +++---- spec/fabricators/pg_team_fabricator.rb | 12 +- spec/fabricators/user_fabricator.rb | 19 +- spec/models/followed_team_spec.rb | 17 -- spec/models/pg_team_spec.rb | 24 ++- spec/models/team_spec.rb | 4 +- spec/models/teams/link_spec.rb | 3 +- spec/models/teams/location_spec.rb | 5 +- spec/models/teams/member_spec.rb | 19 +- spec/models/user_spec.rb | 19 +- spec/models/users/github/repository_spec.rb | 5 +- 32 files changed, 152 insertions(+), 518 deletions(-) delete mode 100644 app/jobs/team_migrator_batch_job.rb delete mode 100644 app/jobs/team_migrator_job.rb delete mode 100644 app/models/concerns/team_migration.rb delete mode 100644 app/models/concerns/team_search.rb delete mode 100644 app/uploaders/team_uploader.rb delete mode 100644 config/initializers/elasticsearch.rb create mode 100644 config/initializers/tire.rb delete mode 100644 db/migrate/20140823103534_add_migration_fields.rb delete mode 100644 db/migrate/20140823174046_fix_pg_team.rb delete mode 100644 spec/models/followed_team_spec.rb diff --git a/Gemfile b/Gemfile index 668e6477..0257ffbb 100644 --- a/Gemfile +++ b/Gemfile @@ -122,9 +122,6 @@ gem 'simple_form' gem 'tweet-button' gem 'local_time' -gem 'elasticsearch-model' -gem 'elasticsearch-rails' - # DROP BEFORE RAILS 4 # Mongo gem 'mongoid' @@ -177,7 +174,6 @@ group :test do gem 'timecop' gem 'vcr' gem 'webmock', '<1.16' - gem 'stripe-ruby-mock', git: 'https://github.com/rebelidealist/stripe-ruby-mock', branch: 'live-tests' end group :production do diff --git a/Gemfile.lock b/Gemfile.lock index 4a7d8d7d..81189b19 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -38,16 +38,6 @@ GIT mime-types (>= 1.25, < 3.0) rest-client (~> 1.4) -GIT - remote: https://github.com/rebelidealist/stripe-ruby-mock - revision: f4229cbe762bc2a5a302cdd83088c283881e9c5a - branch: live-tests - specs: - stripe-ruby-mock (1.10.1.7) - dante (>= 0.2.0) - jimson-temp - stripe (>= 1.15.0) - GEM remote: https://rubygems.org/ remote: https://rails-assets.org/ @@ -116,7 +106,6 @@ GEM rack (>= 0.9.0) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) - blankslate (3.1.3) bson (1.10.2) bson_ext (1.10.2) bson (~> 1.10.2) @@ -184,7 +173,6 @@ GEM httparty (~> 0.10) json curb (0.8.6) - dante (0.2.0) database_cleaner (1.3.0) debug_inspector (0.0.2) debugger-linecache (1.2.0) @@ -204,19 +192,6 @@ GEM execjs eco-source (1.1.0.rc.1) ejs (1.1.1) - elasticsearch (1.0.4) - elasticsearch-api (= 1.0.4) - elasticsearch-transport (= 1.0.4) - elasticsearch-api (1.0.4) - multi_json - elasticsearch-model (0.1.4) - activesupport (> 3) - elasticsearch (> 0.4) - hashie - elasticsearch-rails (0.1.4) - elasticsearch-transport (1.0.4) - faraday - multi_json em-http-request (1.1.2) addressable (>= 2.3.4) cookiejar @@ -346,11 +321,6 @@ GEM jbuilder (2.1.3) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) - jimson-temp (0.9.5) - blankslate (>= 3.1.2) - multi_json (~> 1.0) - rack (~> 1.4) - rest-client (~> 1.0) journey (1.0.4) jquery-rails (2.0.3) railties (>= 3.1.0, < 5.0) @@ -757,8 +727,6 @@ DEPENDENCIES createsend database_cleaner dotenv-rails - elasticsearch-model - elasticsearch-rails ember-rails! fabrication-rails faraday (~> 0.8.1) @@ -838,7 +806,6 @@ DEPENDENCIES spring-commands-rspec squeel (= 1.0.1) stripe! - stripe-ruby-mock! strong_parameters syntax timecop diff --git a/app/jobs/refresh_user_job.rb b/app/jobs/refresh_user_job.rb index ec3be88c..2db6b4cd 100644 --- a/app/jobs/refresh_user_job.rb +++ b/app/jobs/refresh_user_job.rb @@ -7,6 +7,10 @@ def perform(user_id, full=false) user = User.find(user_id) + if user.github_id + user.destroy_github_cache + end + return if !full && user.last_refresh_at > 3.days.ago begin @@ -17,6 +21,7 @@ def perform(user_id, full=false) user.calculate_score! ensure user.touch(:last_refresh_at) + user.destroy_github_cache end end end diff --git a/app/jobs/team_migrator_batch_job.rb b/app/jobs/team_migrator_batch_job.rb deleted file mode 100644 index 60fd1476..00000000 --- a/app/jobs/team_migrator_batch_job.rb +++ /dev/null @@ -1,10 +0,0 @@ -#TODO DELETE ME -class TeamMigratorBatchJob - include Sidekiq::Worker - - def perform - Team.each do |team| - TeamMigratorJob.perform_async(team.id.to_s) - end - end -end \ No newline at end of file diff --git a/app/jobs/team_migrator_job.rb b/app/jobs/team_migrator_job.rb deleted file mode 100644 index a5e333dc..00000000 --- a/app/jobs/team_migrator_job.rb +++ /dev/null @@ -1,169 +0,0 @@ -#TODO DELETE ME -class TeamMigratorJob - include Sidekiq::Worker - - sidekiq_options backtrace: true - - def perform(id) - team = Team.find(id) - if pgteam = find_or_initialize_team(id, team) - extract_account(pgteam, team) - - extract_locations(pgteam, team) - extract_links(pgteam, team) - add_members(pgteam) - add_jobs(pgteam) - convert_followers(pgteam) - add_pending_requests(pgteam, team) - end - end - - - private - - def find_or_initialize_team(id, team) - begin - PgTeam.find_or_initialize_by_mongo_id(id) do |pgteam| - pgteam.name = team.name - pgteam.slug = team.slug - pgteam.created_at = team.created_at - pgteam.updated_at = team.updated_at - pgteam.website = team.website - pgteam.about = team.about - pgteam.total = team.total - pgteam.size = team.size - pgteam.mean = team.mean - pgteam.median = team.median - pgteam.score = team.score - pgteam.twitter = team.twitter - pgteam.facebook = team.facebook - pgteam.premium = team.premium - pgteam.analytics = team.analytics - pgteam.valid_jobs = team.valid_jobs - pgteam.hide_from_featured = team.hide_from_featured - pgteam.preview_code = team.preview_code - pgteam.youtube_url = team.youtube_url - pgteam.github = team.github - pgteam.highlight_tags = team.highlight_tags - pgteam.branding = team.branding - pgteam.headline = team.headline - pgteam.big_quote = team.big_quote - pgteam.big_image = team.big_image - pgteam.featured_banner_image = team.featured_banner_image - pgteam.benefit_name_1 = team.benefit_name_1 - pgteam.benefit_description_1 = team.benefit_description_1 - pgteam.benefit_name_2 = team.benefit_name_2 - pgteam.benefit_description_2 = team.benefit_description_2 - pgteam.benefit_name_3 = team.benefit_name_3 - pgteam.benefit_description_3 = team.benefit_description_3 - pgteam.reason_name_1 = team.reason_name_1 - pgteam.reason_description_1 = team.reason_description_1 - pgteam.reason_name_2 = team.reason_name_2 - pgteam.reason_description_2 = team.reason_description_2 - pgteam.reason_name_3 = team.reason_name_3 - pgteam.reason_description_3 = team.reason_description_3 - pgteam.why_work_image = team.why_work_image - pgteam.organization_way = team.organization_way - pgteam.organization_way_name = team.organization_way_name - pgteam.organization_way_photo = team.organization_way_photo - pgteam.office_photos = team.office_photos - pgteam.upcoming_events = team.upcoming_events - pgteam.featured_links_title = team.featured_links_title - pgteam.blog_feed = team.blog_feed - pgteam.our_challenge = team.our_challenge - pgteam.your_impact = team.your_impact - pgteam.interview_steps = team.interview_steps - pgteam.hiring_tagline = team.hiring_tagline - pgteam.link_to_careers_page = team.link_to_careers_page - # pgteam.avatar = team.avatar - pgteam.achievement_count = team.achievement_count - pgteam.endorsement_count = team.endorsement_count - pgteam.invited_emails = team.invited_emails - pgteam.pending_join_requests = team.pending_join_requests - pgteam.upgraded_at = team.upgraded_at - pgteam.paid_job_posts = team.paid_job_posts - pgteam.monthly_subscription = team.monthly_subscription - pgteam.stack_list = team.stack_list - pgteam.number_of_jobs_to_show = team.number_of_jobs_to_show - pgteam.location = team.location - pgteam.country_id = team.country_id - pgteam.github_organization_name = team.github_organization_name - pgteam.save! - - end - rescue ActiveRecord::RecordInvalid - false - end - end - - def extract_account(pgteam, team) - return unless account = team.account - return if pgteam.account - begin - pgaccount = pgteam.build_account( - stripe_card_token: account.stripe_card_token, - stripe_customer_token: account.stripe_customer_token, - admin_id: account.admin_id - ) - pgaccount.plans << Plan.where(id: account.plan_ids) - pgaccount.save! - rescue ActiveRecord::RecordInvalid => e - # @just3ws, uncomment the following line and get all ID of the corrupted accounts - # raise e - false - end - - end - - def extract_locations(pgteam, team) - locations = team.team_locations - return unless locations.any? - return if pgteam.locations.any? - locations.each do |location| - pgteam.locations.create! name: location.name, - description: location.description, - address: location.address, - city: location.city, - state_code: location.state_code, - country: location.country - - end - end - - def extract_links(pgteam, team) - links = team.featured_links - return if links.empty? - return if pgteam.links.any? - links.each do |link| - pgteam.links.create! name: link.name, - url: link.url - end - end - - def add_members(pgteam) - users = User.where(team_document_id: pgteam.mongo_id) - users.each do |user| - pgteam.members.create! user: user, state: 'active' - end - users.update_all(team_id: pgteam.id) - end - - def add_jobs(pgteam) - Opportunity.where(team_document_id: pgteam.mongo_id).update_all(team_id: pgteam.id) - end - - def convert_followers(pgteam) - FollowedTeam.where(team_document_id: pgteam.mongo_id).update_all(team_id: pgteam.id) - end - - def add_pending_requests(pgteam, team) - pending_team_members = team.pending_team_members - return if pending_team_members.empty? - pending_team_members.each do |pending_team_member| - user = User.find pending_team_member.user_id - pgteam.members.create user: user, - created_at: pending_team_member.created_at, - updated_at: pending_team_member.updated_at - end - end -end \ No newline at end of file diff --git a/app/models/concerns/team_migration.rb b/app/models/concerns/team_migration.rb deleted file mode 100644 index 4be2c68a..00000000 --- a/app/models/concerns/team_migration.rb +++ /dev/null @@ -1,24 +0,0 @@ -module TeamMigration - extend ActiveSupport::Concern - - included do - scope :zombies, -> { where(state: 'zombie') } - end - - module ClassMethods - - def the_walking_deads - active_teams_ids = Teams::Member.pluck(:team_id).uniq - where('id not in (?)', active_teams_ids) - end - - def mark_the_walking_deads! - the_walking_deads.update_all(state: 'zombie') - end - - def kill_zombies! - zombies.destroy_all - end - - end -end \ No newline at end of file diff --git a/app/models/concerns/team_search.rb b/app/models/concerns/team_search.rb deleted file mode 100644 index 56a3658d..00000000 --- a/app/models/concerns/team_search.rb +++ /dev/null @@ -1,8 +0,0 @@ -module TeamSearch - extend ActiveSupport::Concern - included do - include Elasticsearch::Model - - #TODO - end -end \ No newline at end of file diff --git a/app/models/followed_team.rb b/app/models/followed_team.rb index 9e9dfcab..d0b1c96b 100644 --- a/app/models/followed_team.rb +++ b/app/models/followed_team.rb @@ -1,16 +1,13 @@ -# TODO, rename to Teams::Follower class FollowedTeam < ActiveRecord::Base - belongs_to :team, class_name: 'PgTeam' - belongs_to :user end # == Schema Information +# Schema version: 20140728214411 # # Table name: followed_teams # # id :integer not null, primary key # user_id :integer # team_document_id :string(255) -# created_at :datetime default(2012-03-12 21:01:09 UTC) -# team_id :integer +# created_at :datetime default(2014-02-20 22:39:11 UTC) # diff --git a/app/models/pg_team.rb b/app/models/pg_team.rb index e19f9f65..36cf4bc9 100644 --- a/app/models/pg_team.rb +++ b/app/models/pg_team.rb @@ -1,33 +1,24 @@ #Rename to Team when Mongodb is dropped class PgTeam < ActiveRecord::Base - include TeamSearch - include TeamMigration - self.table_name = 'teams' #TODO add inverse_of - has_one :account, class_name: 'Teams::Account', foreign_key: 'team_id', dependent: :delete + has_one :account, class_name: 'Teams::Account', foreign_key: 'team_id', dependent: :destroy - has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id', dependent: :delete_all - has_many :links, class_name: 'Teams::Link', foreign_key: 'team_id', dependent: :delete_all - has_many :locations, class_name: 'Teams::Location', foreign_key: 'team_id', dependent: :delete_all + has_many :members, class_name: 'Teams::Member', foreign_key: 'team_id', dependent: :destroy + has_many :links, class_name: 'Teams::Link', foreign_key: 'team_id', dependent: :destroy + has_many :locations, class_name: 'Teams::Location', foreign_key: 'team_id', dependent: :destroy has_many :jobs, class_name: 'Opportunity', foreign_key: 'team_id', dependent: :destroy - has_many :follows , class_name: 'FollowedTeam', foreign_key: 'team_id', dependent: :destroy - has_many :followers, through: :follows - - accepts_nested_attributes_for :locations, :links, allow_destroy: true, reject_if: :all_blank - - scope :featured, ->{ where(premium: true, valid_jobs: true, hide_from_featured: false) } + before_validation :create_slug! - mount_uploader :avatar, TeamUploader + validates_uniqueness_of :slug - before_validation :create_slug! - validates :slug, uniqueness: true, presence: true + private - private def create_slug! - self.slug = name.parameterize - end + def create_slug! + self.slug = name.parameterize + end end # @@ -78,15 +69,20 @@ class PgTeam < ActiveRecord::Base # organization_way :text # organization_way_name :text # organization_way_photo :text +# office_photos :string(255) default("{}") +# upcoming_events :string(255) default("{}") # featured_links_title :string(255) # blog_feed :text # our_challenge :text # your_impact :text +# interview_steps :string(255) default("{}") # hiring_tagline :text # link_to_careers_page :text # avatar :string(255) # achievement_count :integer default(0) # endorsement_count :integer default(0) +# invited_emails :string(255) default("{}") +# pending_join_requests :string(255) default("{}") # upgraded_at :datetime # paid_job_posts :integer default(0) # monthly_subscription :boolean default(FALSE) @@ -97,11 +93,4 @@ class PgTeam < ActiveRecord::Base # name :string(255) # github_organization_name :string(255) # team_size :integer -# mongo_id :string(255) -# office_photos :string(255) default([]), is an Array -# upcoming_events :text default([]), is an Array -# interview_steps :text default([]), is an Array -# invited_emails :string(255) default([]), is an Array -# pending_join_requests :string(255) default([]), is an Array -# state :string(255) default("active") # diff --git a/app/models/team.rb b/app/models/team.rb index f8a0ee40..b6dead40 100644 --- a/app/models/team.rb +++ b/app/models/team.rb @@ -73,6 +73,7 @@ class Team field :upcoming_events, type: Array, default: [] #just stubbed field :featured_links_title + embeds_many :featured_links, class_name: TeamLink.name field :blog_feed field :our_challenge @@ -95,7 +96,7 @@ class Team field :pending_join_requests, type: Array, default: [] - + embeds_one :account field :upgraded_at field :paid_job_posts, default: 0 field :monthly_subscription, default: false @@ -109,13 +110,9 @@ class Team index({ name: 1 }, { unique: true }) index({ slug: 1 }, { unique: true }) + embeds_many :pending_team_members, class_name: 'TeamMember' - - #migrated embeds_many :team_locations - embeds_one :account - embeds_many :featured_links, class_name: TeamLink.name - embeds_many :pending_team_members, class_name: 'TeamMember' accepts_nested_attributes_for :team_locations, :featured_links, allow_destroy: true, reject_if: :all_blank @@ -129,7 +126,6 @@ class Team after_destroy :reindex_search after_destroy :remove_dependencies - #migrated scope :featured, ->{ where(premium: true, valid_jobs: true, hide_from_featured: false) } class << self @@ -460,27 +456,18 @@ def membership(user) team_members.where(user_id: id_of(user)).first end - #migrated - # .members.top def top_team_member sorted_team_members.first end - #migrated - # .members.top(2) def top_two_team_members sorted_team_members[0...2] || [] end - - #migrated - # .members.top(3) def top_three_team_members sorted_team_members[0...3] || [] end - #migrated - # .members.sorted def sorted_team_members @sorted_team_members = User.where(team_document_id: self.id.to_s).order('score_cache DESC') end @@ -907,9 +894,4 @@ def create_slug! self.slug = self.class.slugify(name) end - after_create do - #'create_pg_team' - TeamMigratorJob.new.perform(self.id.to_s) - end - end diff --git a/app/models/teams/link.rb b/app/models/teams/link.rb index fa826a2f..4e6e6d64 100644 --- a/app/models/teams/link.rb +++ b/app/models/teams/link.rb @@ -2,18 +2,16 @@ class Teams::Link < ActiveRecord::Base belongs_to :team, class_name: 'PgTeam', foreign_key: 'team_id', touch: true - - validates :url, presence: true - validates_uniqueness_of :url, scope: :team_id end # == Schema Information +# Schema version: 20140728214411 # # Table name: teams_links # # id :integer not null, primary key # name :string(255) -# url :text +# url :string(255) # team_id :integer not null # created_at :datetime not null # updated_at :datetime not null diff --git a/app/models/teams/location.rb b/app/models/teams/location.rb index da276a12..64bcee99 100644 --- a/app/models/teams/location.rb +++ b/app/models/teams/location.rb @@ -3,26 +3,17 @@ class Teams::Location < ActiveRecord::Base belongs_to :team, class_name: 'PgTeam', foreign_key: 'team_id', touch: true - - # geocoded_by :address do |obj, results| - # if geo = results.first and obj.address.downcase.include?(geo.city.try(:downcase) || "") - # obj.city = geo.city - # obj.state_code = geo.state_code - # obj.country = geo.country - # end - # end - # - # after_validation :geocode, if: lambda { |team_location| team_location.city.nil? } end # == Schema Information +# Schema version: 20140728214411 # # Table name: teams_locations # # id :integer not null, primary key # name :string(255) -# description :text -# address :text +# description :string(255) +# address :string(255) # city :string(255) # state_code :string(255) # country :string(255) diff --git a/app/models/teams/member.rb b/app/models/teams/member.rb index 77edb7f0..ea61c8a8 100644 --- a/app/models/teams/member.rb +++ b/app/models/teams/member.rb @@ -1,26 +1,26 @@ class Teams::Member < ActiveRecord::Base belongs_to :team, class_name: 'PgTeam', - foreign_key: 'team_id', - counter_cache: :team_size, - touch: true + foreign_key: 'team_id', + counter_cache: :team_size, + touch: true belongs_to :user - - validates_uniqueness_of :user_id, scope: :team_id - - scope :active, -> { where(state: 'active') } - scope :pending, -> { where(state: 'pending') } - scope :sorted, -> { active.joins(:user).order('users.score_cache DESC') } - scope :top, ->(limit= 1) { sorted.limit(limit) } end # == Schema Information +# Schema version: 20140728214411 # # Table name: teams_members # -# id :integer not null, primary key -# team_id :integer not null -# user_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null -# state :string(255) default("pending") +# id :integer not null, primary key +# team_id :integer not null +# user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# team_size :integer default(0) +# badges_count :integer +# email :string(255) +# inviter_id :integer +# name :string(255) +# thumbnail_url :string(255) +# username :string(255) # diff --git a/app/models/user.rb b/app/models/user.rb index 2bed62a2..5008834b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -82,7 +82,6 @@ class User < ActiveRecord::Base has_one :github_profile , class_name: 'Users::Github::Profile', dependent: :destroy has_many :github_repositories, through: :github_profile , source: :repositories - belongs_to :team, class_name: 'PgTeam' geocoded_by :location, latitude: :lat, longitude: :lng, country: :country, state_code: :state_name after_validation :geocode_location, if: :location_changed? unless Rails.env.test? @@ -216,6 +215,13 @@ def team_ids [team_document_id] end + def team + @team ||= team_document_id && Team.find(team_document_id) + rescue Mongoid::Errors::DocumentNotFound + #readonly issue in follows/_user partial from partial iterator + User.connection.execute("UPDATE users set team_document_id = NULL where id = #{self.id}") + @team = nil + end def on_premium_team? team.try(:premium?) || false @@ -615,6 +621,11 @@ def build_repo_followed_activity!(refresh=false) [] end + def destroy_github_cache + GithubRepo.where('owner.github_id' => github_id).destroy if github_id + GithubProfile.where('login' => github).destroy if github + end + def track_user_view!(user) track!("viewed user", user_id: user.id, username: user.username) end @@ -903,8 +914,12 @@ def destroy_badges end end - before_create do - self.referral_token ||= SecureRandom.hex(8) + before_create :make_referral_token + + def make_referral_token + if self.referral_token.nil? + self.referral_token = SecureRandom.hex(8) + end end after_save :refresh_dependencies @@ -959,8 +974,8 @@ def manage_github_orgs # bitbucket :string(255) # codeplex :string(255) # login_count :integer default(0) -# last_request_at :datetime default(2014-07-23 03:14:36 UTC) -# achievements_checked_at :datetime default(1911-08-12 21:49:21 UTC) +# last_request_at :datetime default(2014-07-17 13:10:04 UTC) +# achievements_checked_at :datetime default(1914-02-20 22:39:10 UTC) # claim_code :text # github_id :integer # country :string(255) @@ -970,11 +985,11 @@ def manage_github_orgs # lng :float # http_counter :integer # github_token :string(255) -# twitter_checked_at :datetime default(1911-08-12 21:49:21 UTC) +# twitter_checked_at :datetime default(1914-02-20 22:39:10 UTC) # title :string(255) # company :string(255) # blog :string(255) -# github :citext +# github :string(255) # forrst :string(255) # dribbble :string(255) # specialties :text @@ -1000,6 +1015,7 @@ def manage_github_orgs # referred_by :string(255) # about :text # joined_github_on :date +# joined_twitter_on :date # avatar :string(255) # banner :string(255) # remind_to_invite_team_members :datetime @@ -1007,7 +1023,6 @@ def manage_github_orgs # tracking_code :string(255) # utm_campaign :string(255) # score_cache :float default(0.0) -# gender :string(255) # notify_on_follow :boolean default(TRUE) # api_key :string(255) # remind_to_create_team :datetime @@ -1018,12 +1033,6 @@ def manage_github_orgs # team_responsibilities :text # team_avatar :string(255) # team_banner :string(255) -# stat_name_1 :string(255) -# stat_number_1 :string(255) -# stat_name_2 :string(255) -# stat_number_2 :string(255) -# stat_name_3 :string(255) -# stat_number_3 :string(255) # ip_lat :float # ip_lng :float # penalty :float default(0.0) @@ -1032,15 +1041,11 @@ def manage_github_orgs # resume :string(255) # sourceforge :string(255) # google_code :string(255) -# sales_rep :boolean default(FALSE) # visits :string(255) default("") # visit_frequency :string(255) default("rarely") -# pitchbox_id :integer # join_badge_orgs :boolean default(FALSE) -# use_social_for_pitchbox :boolean default(FALSE) # last_asm_email_at :datetime # banned_at :datetime # last_ip :string(255) # last_ua :string(255) -# team_id :integer # diff --git a/app/models/user_event.rb b/app/models/user_event.rb index 33524fb4..56bdf29d 100644 --- a/app/models/user_event.rb +++ b/app/models/user_event.rb @@ -4,6 +4,7 @@ class UserEvent < ActiveRecord::Base end # == Schema Information +# Schema version: 20140728214411 # # Table name: user_events # @@ -11,5 +12,5 @@ class UserEvent < ActiveRecord::Base # user_id :integer # name :string(255) # data :text -# created_at :datetime default(2012-03-12 21:01:10 UTC) +# created_at :datetime default(2014-02-20 22:39:11 UTC) # diff --git a/app/models/users/github/repository.rb b/app/models/users/github/repository.rb index 3c5d5857..73c6000f 100644 --- a/app/models/users/github/repository.rb +++ b/app/models/users/github/repository.rb @@ -6,6 +6,7 @@ class Users::Github::Repository < ActiveRecord::Base end # == Schema Information +# Schema version: 20140728214411 # # Table name: users_github_repositories # @@ -16,9 +17,9 @@ class Users::Github::Repository < ActiveRecord::Base # homepage :string(255) # fork :boolean default(FALSE) # forks_count :integer default(0) -# forks_count_updated_at :datetime default(2014-07-23 03:14:37 UTC) +# forks_count_updated_at :datetime default(2014-07-18 23:03:00 UTC) # stargazers_count :integer default(0) -# stargazers_count_updated_at :datetime default(2014-07-23 03:14:37 UTC) +# stargazers_count_updated_at :datetime default(2014-07-18 23:03:00 UTC) # language :string(255) # followers_count :integer default(0), not null # github_id :integer not null diff --git a/app/uploaders/team_uploader.rb b/app/uploaders/team_uploader.rb deleted file mode 100644 index a2b1c214..00000000 --- a/app/uploaders/team_uploader.rb +++ /dev/null @@ -1,8 +0,0 @@ -class TeamUploader < CoderwallUploader - - process resize_and_pad: [100, 100] - - def default_url - ActionController::Base.helpers.asset_path 'team-avatar.png' - end -end diff --git a/config/initializers/elasticsearch.rb b/config/initializers/elasticsearch.rb deleted file mode 100644 index 69afc387..00000000 --- a/config/initializers/elasticsearch.rb +++ /dev/null @@ -1,5 +0,0 @@ -Tire.configure do - url ENV['ELASTICSEARCH_URL'] -end - -Elasticsearch::Model.client = Elasticsearch::Client.new url: ENV['ELASTICSEARCH_URL'] \ No newline at end of file diff --git a/config/initializers/tire.rb b/config/initializers/tire.rb new file mode 100644 index 00000000..b5967957 --- /dev/null +++ b/config/initializers/tire.rb @@ -0,0 +1,3 @@ +Tire.configure do + url ENV['ELASTICSEARCH_URL'] +end diff --git a/db/migrate/20140823103534_add_migration_fields.rb b/db/migrate/20140823103534_add_migration_fields.rb deleted file mode 100644 index db21cb30..00000000 --- a/db/migrate/20140823103534_add_migration_fields.rb +++ /dev/null @@ -1,7 +0,0 @@ -class AddMigrationFields < ActiveRecord::Migration - def up - add_column :teams, :mongo_id, :string, unique: true - add_column :teams_members, :state, :string, unique: true , default: 'pending' - add_column :users, :team_id, :integer, index: true - end -end diff --git a/db/migrate/20140823174046_fix_pg_team.rb b/db/migrate/20140823174046_fix_pg_team.rb deleted file mode 100644 index 1262b1e9..00000000 --- a/db/migrate/20140823174046_fix_pg_team.rb +++ /dev/null @@ -1,26 +0,0 @@ -class FixPgTeam < ActiveRecord::Migration - def up - remove_column :teams, :office_photos - add_column :teams, :office_photos, :string, array: true, default: [] - remove_column :teams, :upcoming_events - add_column :teams, :upcoming_events, :text, array: true, default: [] - remove_column :teams, :interview_steps - add_column :teams, :interview_steps, :text, array: true, default: [] - remove_column :teams, :invited_emails - add_column :teams, :invited_emails, :string, array: true, default: [] - remove_column :teams, :pending_join_requests - add_column :teams, :pending_join_requests, :string, array: true, default: [] - add_column :teams, :state, :string, default: 'active' - change_column :teams_locations, :description, :text - change_column :teams_locations, :address, :text - change_column :teams_links, :url, :text - add_column :followed_teams, :team_id, :integer, index: true - remove_column :teams_members, :team_size - remove_column :teams_members, :badges_count - remove_column :teams_members, :email - remove_column :teams_members, :inviter_id - remove_column :teams_members, :name - remove_column :teams_members, :thumbnail_url - remove_column :teams_members, :username - end -end diff --git a/db/schema.rb b/db/schema.rb index f4881ffd..e6738cdb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,10 +11,9 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140823174046) do +ActiveRecord::Schema.define(:version => 20140807214719) do add_extension "citext" - add_extension "hstore" create_table "alias_tags", :id => false, :force => true do |t| t.integer "tag_id" @@ -105,8 +104,7 @@ create_table "followed_teams", :force => true do |t| t.integer "user_id" t.string "team_document_id" - t.datetime "created_at", :default => '2012-03-12 21:01:09' - t.integer "team_id" + t.datetime "created_at", :default => '2014-02-20 22:39:11' end add_index "followed_teams", ["team_document_id"], :name => "index_followed_teams_on_team_document_id" @@ -355,8 +353,8 @@ end create_table "teams", :force => true do |t| - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "website" t.text "about" t.integer "total", :default => 0 @@ -396,15 +394,20 @@ t.text "organization_way" t.text "organization_way_name" t.text "organization_way_photo" + t.string "office_photos", :default => [], :array => true + t.string "upcoming_events", :default => [], :array => true t.string "featured_links_title" t.text "blog_feed" t.text "our_challenge" t.text "your_impact" + t.string "interview_steps", :default => [], :array => true t.text "hiring_tagline" t.text "link_to_careers_page" t.string "avatar" t.integer "achievement_count", :default => 0 t.integer "endorsement_count", :default => 0 + t.string "invited_emails", :default => [], :array => true + t.string "pending_join_requests", :default => [], :array => true t.datetime "upgraded_at" t.integer "paid_job_posts", :default => 0 t.boolean "monthly_subscription", :default => false @@ -415,13 +418,6 @@ t.string "name" t.string "github_organization_name" t.integer "team_size" - t.string "mongo_id" - t.string "office_photos", :default => [], :array => true - t.text "upcoming_events", :default => [], :array => true - t.text "interview_steps", :default => [], :array => true - t.string "invited_emails", :default => [], :array => true - t.string "pending_join_requests", :default => [], :array => true - t.string "state", :default => "active" end create_table "teams_account_plans", :id => false, :force => true do |t| @@ -441,7 +437,7 @@ create_table "teams_links", :force => true do |t| t.string "name" - t.text "url" + t.string "url" t.integer "team_id", :null => false t.datetime "created_at", :null => false t.datetime "updated_at", :null => false @@ -449,8 +445,8 @@ create_table "teams_locations", :force => true do |t| t.string "name" - t.text "description" - t.text "address" + t.string "description" + t.string "address" t.string "city" t.string "state_code" t.string "country" @@ -460,11 +456,17 @@ end create_table "teams_members", :force => true do |t| - t.integer "team_id", :null => false - t.integer "user_id", :null => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.string "state", :default => "pending" + t.integer "team_id", :null => false + t.integer "user_id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "team_size", :default => 0 + t.integer "badges_count" + t.string "email" + t.integer "inviter_id" + t.string "name" + t.string "thumbnail_url" + t.string "username" end create_table "tokens", :force => true do |t| @@ -482,7 +484,7 @@ t.integer "user_id" t.string "name" t.text "data" - t.datetime "created_at", :default => '2012-03-12 21:01:10' + t.datetime "created_at", :default => '2014-02-20 22:39:11' end create_table "users", :force => true do |t| @@ -503,8 +505,8 @@ t.string "bitbucket" t.string "codeplex" t.integer "login_count", :default => 0 - t.datetime "last_request_at", :default => '2014-07-23 03:14:36' - t.datetime "achievements_checked_at", :default => '1911-08-12 21:49:21' + t.datetime "last_request_at", :default => '2014-07-17 13:10:04' + t.datetime "achievements_checked_at", :default => '1914-02-20 22:39:10' t.text "claim_code" t.integer "github_id" t.string "country" @@ -514,7 +516,7 @@ t.float "lng" t.integer "http_counter" t.string "github_token" - t.datetime "twitter_checked_at", :default => '1911-08-12 21:49:21' + t.datetime "twitter_checked_at", :default => '1914-02-20 22:39:10' t.string "title" t.string "company" t.string "blog" @@ -551,7 +553,6 @@ t.string "tracking_code" t.string "utm_campaign" t.float "score_cache", :default => 0.0 - t.string "gender" t.boolean "notify_on_follow", :default => true t.string "api_key" t.datetime "remind_to_create_team" @@ -562,12 +563,6 @@ t.text "team_responsibilities" t.string "team_avatar" t.string "team_banner" - t.string "stat_name_1" - t.string "stat_number_1" - t.string "stat_name_2" - t.string "stat_number_2" - t.string "stat_name_3" - t.string "stat_number_3" t.float "ip_lat" t.float "ip_lng" t.float "penalty", :default => 0.0 @@ -576,17 +571,13 @@ t.string "resume" t.string "sourceforge" t.string "google_code" - t.boolean "sales_rep", :default => false t.string "visits", :default => "" t.string "visit_frequency", :default => "rarely" - t.integer "pitchbox_id" t.boolean "join_badge_orgs", :default => false - t.boolean "use_social_for_pitchbox", :default => false t.datetime "last_asm_email_at" t.datetime "banned_at" t.string "last_ip" t.string "last_ua" - t.integer "team_id" end add_index "users", ["linkedin_id"], :name => "index_users_on_linkedin_id", :unique => true @@ -646,9 +637,9 @@ t.string "homepage" t.boolean "fork", :default => false t.integer "forks_count", :default => 0 - t.datetime "forks_count_updated_at", :default => '2014-07-23 03:14:37' + t.datetime "forks_count_updated_at", :default => '2014-07-18 23:03:00' t.integer "stargazers_count", :default => 0 - t.datetime "stargazers_count_updated_at", :default => '2014-07-23 03:14:37' + t.datetime "stargazers_count_updated_at", :default => '2014-07-18 23:03:00' t.string "language" t.integer "followers_count", :default => 0, :null => false t.integer "github_id", :null => false diff --git a/spec/fabricators/pg_team_fabricator.rb b/spec/fabricators/pg_team_fabricator.rb index 260ae47b..436b95f4 100644 --- a/spec/fabricators/pg_team_fabricator.rb +++ b/spec/fabricators/pg_team_fabricator.rb @@ -47,15 +47,20 @@ # organization_way :text # organization_way_name :text # organization_way_photo :text +# office_photos :string(255) default("{}") +# upcoming_events :string(255) default("{}") # featured_links_title :string(255) # blog_feed :text # our_challenge :text # your_impact :text +# interview_steps :string(255) default("{}") # hiring_tagline :text # link_to_careers_page :text # avatar :string(255) # achievement_count :integer default(0) # endorsement_count :integer default(0) +# invited_emails :string(255) default("{}") +# pending_join_requests :string(255) default("{}") # upgraded_at :datetime # paid_job_posts :integer default(0) # monthly_subscription :boolean default(FALSE) @@ -66,11 +71,4 @@ # name :string(255) # github_organization_name :string(255) # team_size :integer -# mongo_id :string(255) -# office_photos :string(255) default([]), is an Array -# upcoming_events :text default([]), is an Array -# interview_steps :text default([]), is an Array -# invited_emails :string(255) default([]), is an Array -# pending_join_requests :string(255) default([]), is an Array -# state :string(255) default("active") # diff --git a/spec/fabricators/user_fabricator.rb b/spec/fabricators/user_fabricator.rb index 1c838021..41cb4d3b 100644 --- a/spec/fabricators/user_fabricator.rb +++ b/spec/fabricators/user_fabricator.rb @@ -41,8 +41,8 @@ # bitbucket :string(255) # codeplex :string(255) # login_count :integer default(0) -# last_request_at :datetime default(2014-07-23 03:14:36 UTC) -# achievements_checked_at :datetime default(1911-08-12 21:49:21 UTC) +# last_request_at :datetime default(2014-07-17 13:10:04 UTC) +# achievements_checked_at :datetime default(1914-02-20 22:39:10 UTC) # claim_code :text # github_id :integer # country :string(255) @@ -52,11 +52,11 @@ # lng :float # http_counter :integer # github_token :string(255) -# twitter_checked_at :datetime default(1911-08-12 21:49:21 UTC) +# twitter_checked_at :datetime default(1914-02-20 22:39:10 UTC) # title :string(255) # company :string(255) # blog :string(255) -# github :citext +# github :string(255) # forrst :string(255) # dribbble :string(255) # specialties :text @@ -89,7 +89,6 @@ # tracking_code :string(255) # utm_campaign :string(255) # score_cache :float default(0.0) -# gender :string(255) # notify_on_follow :boolean default(TRUE) # api_key :string(255) # remind_to_create_team :datetime @@ -100,12 +99,6 @@ # team_responsibilities :text # team_avatar :string(255) # team_banner :string(255) -# stat_name_1 :string(255) -# stat_number_1 :string(255) -# stat_name_2 :string(255) -# stat_number_2 :string(255) -# stat_name_3 :string(255) -# stat_number_3 :string(255) # ip_lat :float # ip_lng :float # penalty :float default(0.0) @@ -114,15 +107,11 @@ # resume :string(255) # sourceforge :string(255) # google_code :string(255) -# sales_rep :boolean default(FALSE) # visits :string(255) default("") # visit_frequency :string(255) default("rarely") -# pitchbox_id :integer # join_badge_orgs :boolean default(FALSE) -# use_social_for_pitchbox :boolean default(FALSE) # last_asm_email_at :datetime # banned_at :datetime # last_ip :string(255) # last_ua :string(255) -# team_id :integer # diff --git a/spec/models/followed_team_spec.rb b/spec/models/followed_team_spec.rb deleted file mode 100644 index cc7d41d4..00000000 --- a/spec/models/followed_team_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# == Schema Information -# -# Table name: followed_teams -# -# id :integer not null, primary key -# user_id :integer -# team_document_id :string(255) -# created_at :datetime default(2012-03-12 21:01:09 UTC) -# team_id :integer -# - -require 'rails_helper' - -RSpec.describe FollowedTeam, :type => :model do - it {is_expected.to belong_to(:team)} - it {is_expected.to belong_to(:user)} -end diff --git a/spec/models/pg_team_spec.rb b/spec/models/pg_team_spec.rb index a1f079fe..e602c575 100644 --- a/spec/models/pg_team_spec.rb +++ b/spec/models/pg_team_spec.rb @@ -1,14 +1,12 @@ require 'rails_helper' RSpec.describe PgTeam, :type => :model do - it { is_expected.to have_one :account } - - it { is_expected.to have_many :locations } - it { is_expected.to have_many :links } - it { is_expected.to have_many :members } - it { is_expected.to have_many :jobs } - it { is_expected.to have_many :followers } + it {is_expected.to have_one :account} + it {is_expected.to have_many :locations} + it {is_expected.to have_many :links} + it {is_expected.to have_many :members} + it {is_expected.to have_many :jobs} end # == Schema Information @@ -57,15 +55,20 @@ # organization_way :text # organization_way_name :text # organization_way_photo :text +# office_photos :string(255) default("{}") +# upcoming_events :string(255) default("{}") # featured_links_title :string(255) # blog_feed :text # our_challenge :text # your_impact :text +# interview_steps :string(255) default("{}") # hiring_tagline :text # link_to_careers_page :text # avatar :string(255) # achievement_count :integer default(0) # endorsement_count :integer default(0) +# invited_emails :string(255) default("{}") +# pending_join_requests :string(255) default("{}") # upgraded_at :datetime # paid_job_posts :integer default(0) # monthly_subscription :boolean default(FALSE) @@ -76,11 +79,4 @@ # name :string(255) # github_organization_name :string(255) # team_size :integer -# mongo_id :string(255) -# office_photos :string(255) default([]), is an Array -# upcoming_events :text default([]), is an Array -# interview_steps :text default([]), is an Array -# invited_emails :string(255) default([]), is an Array -# pending_join_requests :string(255) default([]), is an Array -# state :string(255) default("active") # diff --git a/spec/models/team_spec.rb b/spec/models/team_spec.rb index b99251d6..92a5078d 100644 --- a/spec/models/team_spec.rb +++ b/spec/models/team_spec.rb @@ -10,10 +10,10 @@ end it 'should indicate if team member has referral' do - member_that_invited_user = Fabricate(:user) + member_that_invited_user = Fabricate(:user, referral_token: 'asdfasdf') team.add_user(member_that_invited_user) - expect(team.has_user_with_referral_token?(member_that_invited_user.referral_token)).to eq(true) + expect(team.has_user_with_referral_token?('asdfasdf')).to eq(true) expect(team.has_user_with_referral_token?("something else")).to eq(false) end diff --git a/spec/models/teams/link_spec.rb b/spec/models/teams/link_spec.rb index cb0eb9d0..7f2a1583 100644 --- a/spec/models/teams/link_spec.rb +++ b/spec/models/teams/link_spec.rb @@ -5,12 +5,13 @@ end # == Schema Information +# Schema version: 20140728214411 # # Table name: teams_links # # id :integer not null, primary key # name :string(255) -# url :text +# url :string(255) # team_id :integer not null # created_at :datetime not null # updated_at :datetime not null diff --git a/spec/models/teams/location_spec.rb b/spec/models/teams/location_spec.rb index acb8a835..2b992ff1 100644 --- a/spec/models/teams/location_spec.rb +++ b/spec/models/teams/location_spec.rb @@ -5,13 +5,14 @@ end # == Schema Information +# Schema version: 20140728214411 # # Table name: teams_locations # # id :integer not null, primary key # name :string(255) -# description :text -# address :text +# description :string(255) +# address :string(255) # city :string(255) # state_code :string(255) # country :string(255) diff --git a/spec/models/teams/member_spec.rb b/spec/models/teams/member_spec.rb index 78a259cc..356e2c79 100644 --- a/spec/models/teams/member_spec.rb +++ b/spec/models/teams/member_spec.rb @@ -6,13 +6,20 @@ end # == Schema Information +# Schema version: 20140728214411 # # Table name: teams_members # -# id :integer not null, primary key -# team_id :integer not null -# user_id :integer not null -# created_at :datetime not null -# updated_at :datetime not null -# state :string(255) default("pending") +# id :integer not null, primary key +# team_id :integer not null +# user_id :integer not null +# created_at :datetime not null +# updated_at :datetime not null +# team_size :integer default(0) +# badges_count :integer +# email :string(255) +# inviter_id :integer +# name :string(255) +# thumbnail_url :string(255) +# username :string(255) # diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9e6afafb..34190fec 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -356,8 +356,8 @@ class AlsoNotaBadge < BadgeBase # bitbucket :string(255) # codeplex :string(255) # login_count :integer default(0) -# last_request_at :datetime default(2014-07-23 03:14:36 UTC) -# achievements_checked_at :datetime default(1911-08-12 21:49:21 UTC) +# last_request_at :datetime default(2014-07-17 13:10:04 UTC) +# achievements_checked_at :datetime default(1914-02-20 22:39:10 UTC) # claim_code :text # github_id :integer # country :string(255) @@ -367,11 +367,11 @@ class AlsoNotaBadge < BadgeBase # lng :float # http_counter :integer # github_token :string(255) -# twitter_checked_at :datetime default(1911-08-12 21:49:21 UTC) +# twitter_checked_at :datetime default(1914-02-20 22:39:10 UTC) # title :string(255) # company :string(255) # blog :string(255) -# github :citext +# github :string(255) # forrst :string(255) # dribbble :string(255) # specialties :text @@ -404,7 +404,6 @@ class AlsoNotaBadge < BadgeBase # tracking_code :string(255) # utm_campaign :string(255) # score_cache :float default(0.0) -# gender :string(255) # notify_on_follow :boolean default(TRUE) # api_key :string(255) # remind_to_create_team :datetime @@ -415,12 +414,6 @@ class AlsoNotaBadge < BadgeBase # team_responsibilities :text # team_avatar :string(255) # team_banner :string(255) -# stat_name_1 :string(255) -# stat_number_1 :string(255) -# stat_name_2 :string(255) -# stat_number_2 :string(255) -# stat_name_3 :string(255) -# stat_number_3 :string(255) # ip_lat :float # ip_lng :float # penalty :float default(0.0) @@ -429,15 +422,11 @@ class AlsoNotaBadge < BadgeBase # resume :string(255) # sourceforge :string(255) # google_code :string(255) -# sales_rep :boolean default(FALSE) # visits :string(255) default("") # visit_frequency :string(255) default("rarely") -# pitchbox_id :integer # join_badge_orgs :boolean default(FALSE) -# use_social_for_pitchbox :boolean default(FALSE) # last_asm_email_at :datetime # banned_at :datetime # last_ip :string(255) # last_ua :string(255) -# team_id :integer # diff --git a/spec/models/users/github/repository_spec.rb b/spec/models/users/github/repository_spec.rb index 992a3e24..7516e03f 100644 --- a/spec/models/users/github/repository_spec.rb +++ b/spec/models/users/github/repository_spec.rb @@ -20,6 +20,7 @@ end # == Schema Information +# Schema version: 20140728214411 # # Table name: users_github_repositories # @@ -30,9 +31,9 @@ # homepage :string(255) # fork :boolean default(FALSE) # forks_count :integer default(0) -# forks_count_updated_at :datetime default(2014-07-23 03:14:37 UTC) +# forks_count_updated_at :datetime default(2014-07-18 23:03:00 UTC) # stargazers_count :integer default(0) -# stargazers_count_updated_at :datetime default(2014-07-23 03:14:37 UTC) +# stargazers_count_updated_at :datetime default(2014-07-18 23:03:00 UTC) # language :string(255) # followers_count :integer default(0), not null # github_id :integer not null