Skip to content

Commit f43eaec

Browse files
committed
WIP: Removing MongoDB models
1 parent 082234d commit f43eaec

File tree

101 files changed

+1235
-309
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+1235
-309
lines changed

Gemfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ gem 'tire'
144144

145145
group :development do
146146
gem 'better_errors'
147+
gem 'binding_of_caller'
147148
gem 'flog'
148149
gem 'fukuzatsu'
149150
gem 'guard-rspec'
@@ -155,16 +156,17 @@ group :development do
155156
end
156157

157158
group :development, :test do
159+
gem 'annotate'
158160
gem 'fabrication-rails'
159161
gem 'ffaker'
160162
gem 'jazz_hands', github: 'nixme/jazz_hands', branch: 'bring-your-own-debugger'
161163
gem 'launchy'
162164
gem 'pry-byebug'
163165
gem 'pry-rescue'
166+
gem 'pry-stack_explorer'
164167
gem 'quiet_assets'
165-
gem 'syntax'
166-
gem 'annotate'
167168
gem 'rspec-rails'
169+
gem 'syntax'
168170
end
169171

170172
group :test do

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ DEPENDENCIES
744744
awesome_print
745745
backbone-on-rails
746746
better_errors
747+
binding_of_caller
747748
bson_ext
748749
capybara
749750
capybara-screenshot
@@ -809,6 +810,7 @@ DEPENDENCIES
809810
postgres_ext
810811
pry-byebug
811812
pry-rescue
813+
pry-stack_explorer
812814
pubnub (= 0.1.9)
813815
puma
814816
querystring

app/controllers/accounts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def ensure_account_admin
7979
end
8080

8181
def determine_plan
82-
chosen_plan = params[:account].delete(:chosen_plan)
82+
chosen_plan = params[:teams_account].delete(:chosen_plan)
8383
@plan = Plan.find_by_public_id(chosen_plan)
8484
end
8585

app/controllers/teams_controller.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def create
8080
create_params = params.require(:team).permit(:selected, :slug, :name)
8181

8282
@team, confirmed = selected_or_new(create_params)
83-
@teams = Team.any_of({ :name => /#{team_to_regex(@team)}.*/i }).limit(3).to_a unless confirmed
83+
#@teams = Team.any_of({ :name => /#{team_to_regex(@team)}.*/i }).limit(3).to_a unless confirmed
84+
@teams = Team.where('name ilike ?', "#{@team}%").limit(3) unless confirmed
8485

8586
if @team.valid? and @teams.blank? and @team.new_record?
8687
@team.add_user(current_user)
@@ -90,6 +91,10 @@ def create
9091
end
9192
end
9293

94+
#def team_to_regex(team)
95+
#team.name.gsub(/ \-\./, '.*')
96+
#end
97+
9398
def edit
9499
edit_params = params.permit(:slug, :id)
95100

@@ -299,10 +304,6 @@ def previous_job(job)
299304
Opportunity.with_public_id(public_id) unless public_id.nil?
300305
end
301306

302-
def team_to_regex(team)
303-
team.name.gsub(/ \-\./, '.*')
304-
end
305-
306307
def selected_or_new(opts)
307308
team = Team.new(name: opts[:name])
308309
confirm = false

app/controllers/usernames_controller.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
class UsernamesController < ApplicationController
22
skip_before_action :require_registration
33

4+
# TODO: Clean up the config/routes for /usernames
5+
# There is no UsernamesController#index for example. Why is there a route?
6+
47
def show
58
# allow validation to pass if it's the user's username that they're trying to validate (for edit username)
69
if signed_in? && current_user.username.downcase == params[:id].downcase
@@ -11,4 +14,4 @@ def show
1114
head :ok
1215
end
1316
end
14-
end
17+
end

app/helpers/teams_helper.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def team_job_path(team)
155155
teamname_path(slug: team.slug) + "#open-positions"
156156
end
157157

158-
def edit_team_locations_path(team)
158+
def edit_s_path(team)
159159
teamname_path(slug: team.slug) + "/edit/#locations"
160160
end
161161

@@ -194,4 +194,4 @@ def team_twitter_link(team)
194194
end
195195

196196

197-
end
197+
end

app/models/api_access.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def can_award?(badge_name)
1313
end
1414

1515
# == Schema Information
16-
# Schema version: 20140728214411
16+
# Schema version: 20140918031936
1717
#
1818
# Table name: api_accesses
1919
#

app/models/available_coupon.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class AvailableCoupon < ActiveRecord::Base
22
end
33

44
# == Schema Information
5-
# Schema version: 20140728214411
5+
# Schema version: 20140918031936
66
#
77
# Table name: available_coupons
88
#

app/models/badge.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def event_type
9898
end
9999

100100
# == Schema Information
101-
# Schema version: 20140728214411
101+
# Schema version: 20140918031936
102102
#
103103
# Table name: badges
104104
#

app/models/comment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def analyze_spam
138138
end
139139

140140
# == Schema Information
141-
# Schema version: 20140728214411
141+
# Schema version: 20140918031936
142142
#
143143
# Table name: comments
144144
#

app/models/concerns/team_analytics.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def detailed_visitors(since = 0)
2323

2424
def simple_visitors(since = 0)
2525
all_visitors = Redis.current.zrangebyscore(user_views_key, since, Time.now.to_i, withscores: true) +
26-
Redis.current.zrangebyscore(user_anon_views_key, since, Time.now.to_i, withscores: true)
26+
Redis.current.zrangebyscore(user_anon_views_key, since, Time.now.to_i, withscores: true)
2727
Hash[*all_visitors.flatten].map do |viewer_id, timestamp|
2828
visitor_data(nil, nil, nil, 0, viewer_id, timestamp, identify_visitor(viewer_id))
2929
end
@@ -71,17 +71,18 @@ def number_of_completed_sections(*excluded_sections)
7171
end
7272
sections.each do |section_complete|
7373
completed_sections += 1 if self.respond_to?(section_complete) &&
74-
public_send(section_complete)
74+
public_send(section_complete)
7575
end
7676
completed_sections
7777
end
7878

7979
private
80-
def some_crappy_method(hash_string_to_parse)
81-
# This code is bad and Mike should feel bad.
82-
JSON.parse('{' + hash_string_to_parse.gsub(/^{|}$/, '').split(', ')
80+
81+
def some_crappy_method(hash_string_to_parse)
82+
# This code is bad and Mike should feel bad.
83+
JSON.parse('{' + hash_string_to_parse.gsub(/^{|}$/, '').split(', ')
8384
.map { |pair| pair.split('=>') }
8485
.map { |k, v| [k.gsub(/^:(\w*)/, '"\1"'), v == 'nil' ? 'null' : v].join(': ') }.join(', ') + '}')
85-
end
86+
end
8687
end
8788
end

app/models/country.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Country < ActiveRecord::Base
22
end
33

44
# == Schema Information
5-
# Schema version: 20140728214411
5+
# Schema version: 20140918031936
66
#
77
# Table name: countries
88
#

app/models/endorsement.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def event_type
2323
end
2424

2525
# == Schema Information
26-
# Schema version: 20140728214411
26+
# Schema version: 20140918031936
2727
#
2828
# Table name: endorsements
2929
#

app/models/fact.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def user
6464
end
6565

6666
# == Schema Information
67-
# Schema version: 20140728214411
67+
# Schema version: 20140918031936
6868
#
6969
# Table name: facts
7070
#

app/models/follow.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def event_type
3636
end
3737

3838
# == Schema Information
39-
# Schema version: 20140728214411
39+
# Schema version: 20140918031936
4040
#
4141
# Table name: follows
4242
#

app/models/followed_team.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ class FollowedTeam < ActiveRecord::Base
44
end
55

66
# == Schema Information
7+
# Schema version: 20140918031936
78
#
89
# Table name: followed_teams
910
#

app/models/github_assignment.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def self.for_github_username(github_username)
1818
end
1919

2020
# == Schema Information
21-
# Schema version: 20140728214411
21+
# Schema version: 20140918031936
2222
#
2323
# Table name: github_assignments
2424
#

app/models/highlight.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def add_to_timeline
2222
end
2323

2424
# == Schema Information
25-
# Schema version: 20140728214411
25+
# Schema version: 20140918031936
2626
#
2727
# Table name: highlights
2828
#

app/models/invitation.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class Invitation < ActiveRecord::Base
22
end
33

44
# == Schema Information
5-
# Schema version: 20140728214411
5+
# Schema version: 20140918031936
66
#
77
# Table name: invitations
88
#
@@ -14,4 +14,5 @@ class Invitation < ActiveRecord::Base
1414
# inviter_id :integer
1515
# created_at :datetime
1616
# updated_at :datetime
17+
# team_id :integer
1718
#

app/models/like.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def liked_callback
1616
end
1717

1818
# == Schema Information
19-
# Schema version: 20140728214411
19+
# Schema version: 20140918031936
2020
#
2121
# Table name: likes
2222
#

app/models/network.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ def assign_members
234234
end
235235

236236
# == Schema Information
237-
# Schema version: 20140728214411
237+
# Schema version: 20140918031936
238238
#
239239
# Table name: networks
240240
#

app/models/network_expert.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class NetworkExpert < ActiveRecord::Base
88
end
99

1010
# == Schema Information
11-
# Schema version: 20140728214411
11+
# Schema version: 20140918031936
1212
#
1313
# Table name: network_experts
1414
#

app/models/opportunity.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Opportunity < ActiveRecord::Base
2121
validates :location_city, presence: true, allow_blank: false, unless: lambda { location && anywhere?(location) }
2222
validates :salary, presence: true, numericality: true, inclusion: 0..800_000, allow_blank: true
2323
validates :team_document_id, presence: true
24-
24+
2525

2626
before_validation :set_location_city
2727
before_save :update_cached_tags
@@ -39,7 +39,7 @@ class Opportunity < ActiveRecord::Base
3939

4040
attr_accessor :title
4141

42-
42+
4343
HUMANIZED_ATTRIBUTES = {
4444
name: "Title"
4545
}
@@ -277,12 +277,12 @@ def add_opportunity_locations_to_team
277277
geocoded_all = true
278278
location.split('|').each do |location_string|
279279
# skip if location is anywhere or already exists
280-
if anywhere?(location_string) || team.team_locations.where(address: /.*#{location_string}.*/).count > 0
280+
if anywhere?(location_string) || team.locations.where(address: /.*#{location_string}.*/).count > 0
281281
geocoded_all = false
282282
next
283283
end
284284

285-
geocoded_all &&= team.team_locations.build(address: location_string, name: location_string).geocode
285+
geocoded_all &&= team.locations.build(address: location_string, name: location_string).geocode
286286
end
287287
geocoded_all || nil
288288
end
@@ -305,7 +305,7 @@ def remove_from_index
305305
end
306306

307307
# == Schema Information
308-
# Schema version: 20140728214411
308+
# Schema version: 20140918031936
309309
#
310310
# Table name: opportunities
311311
#

0 commit comments

Comments
 (0)