Skip to content

Commit 5be30dc

Browse files
committed
Cleaning up to get the new data working
1 parent 864349e commit 5be30dc

File tree

7 files changed

+73
-71
lines changed

7 files changed

+73
-71
lines changed

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ namespace :team do
3030
#
3131

3232
task verify: :environment do
33-
ActiveRecord::Base.logger = nil
34-
Mongoid.logger = nil
35-
Moped.logger = nil
33+
#ActiveRecord::Base.logger = nil
34+
#Mongoid.logger = nil
35+
#Moped.logger = nil
3636

3737
PgTeam.find_each(batch_size: 100) do |pg_team|
3838
begin

app/controllers/protips_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ProtipsController < ApplicationController
1919
layout :choose_protip_layout
2020

2121
def index
22-
if !params[:search].blank?
22+
if params[:search].present?
2323
search
2424
elsif signed_in?
2525
trending
@@ -136,7 +136,7 @@ def show
136136

137137
return redirect_to protip_missing_destination, notice: "The pro tip you were looking for no longer exists" if @protip.nil?
138138
return redirect_to protip_path(@protip.public_id<<'/'<<@protip.friendly_id, :p => params[:p], :q => params[:q]) if params[:slug]!=@protip.friendly_id
139-
139+
140140
@comments = @protip.comments
141141
@reply_to = show_params[:reply_to]
142142
@next_protip = Protip.search_next(show_params[:q], show_params[:t], show_params[:i], show_params[:p]) if is_admin?

app/helpers/teams_helper.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ def show_team_score?
9898
@team.size >= 3 && @team.rank > 0
9999
end
100100

101-
102101
def friendly_team_path(team)
103102
teamname_path(slug: team.slug)
104103
end

app/models/concerns/protip_mapping.rb

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -3,62 +3,62 @@ module ProtipMapping
33

44
included do
55
settings analysis: {
6-
analyzer: {
7-
comma: {"type" => "pattern",
8-
"pattern" => ",",
9-
"filter" => "keyword"
10-
}
6+
analyzer: {
7+
comma: {"type" => "pattern",
8+
"pattern" => ",",
9+
"filter" => "keyword"
10+
}
1111

12-
}
12+
}
1313
}
1414

1515
mapping show: {properties: {
16-
public_id: {type: 'string', index: 'not_analyzed'},
17-
kind: {type: 'string', index: 'not_analyzed'},
16+
public_id: {type: 'string', index: 'not_analyzed'},
17+
kind: {type: 'string', index: 'not_analyzed'},
18+
title: {type: 'string', boost: 100, analyzer: 'snowball'},
19+
body: {type: 'string', boost: 80, analyzer: 'snowball'},
20+
html: {type: 'string', index: 'not_analyzed'},
21+
tags: {type: 'string', boost: 80, analyzer: 'comma'},
22+
upvotes: {type: 'integer', index: 'not_analyzed'},
23+
url: {type: 'string', index: 'not_analyzed'},
24+
upvote_path: {type: 'string', index: 'not_analyzed'},
25+
popular_score: {type: 'double', index: 'not_analyzed'},
26+
score: {type: 'double', index: 'not_analyzed'},
27+
trending_score: {type: 'double', index: 'not_analyzed'},
28+
only_link: {type: 'string', index: 'not_analyzed'},
29+
link: {type: 'string', index: 'not_analyzed'},
30+
team: {type: 'multi_field', index: 'not_analyzed', fields: {
31+
name: {type: 'string', index: 'snowball'},
32+
slug: {type: 'string', boost: 50, index: 'snowball'},
33+
avatar: {type: 'string', index: 'not_analyzed'},
34+
profile_path: {type: 'string', index: 'not_analyzed'},
35+
hiring: {type: 'boolean', index: 'not_analyzed'}
36+
}},
37+
views_count: {type: 'integer', index: 'not_analyzed'},
38+
comments_count: {type: 'integer', index: 'not_analyzed'},
39+
best_stat: {type: 'multi_field', index: 'not_analyzed', fields: {
40+
name: {type: 'string', index: 'not_analyzed'},
41+
value: {type: 'integer', index: 'not_analyzed'},
42+
}},
43+
comments: {type: 'object', index: 'not_analyzed', properties: {
1844
title: {type: 'string', boost: 100, analyzer: 'snowball'},
1945
body: {type: 'string', boost: 80, analyzer: 'snowball'},
20-
html: {type: 'string', index: 'not_analyzed'},
21-
tags: {type: 'string', boost: 80, analyzer: 'comma'},
22-
upvotes: {type: 'integer', index: 'not_analyzed'},
23-
url: {type: 'string', index: 'not_analyzed'},
24-
upvote_path: {type: 'string', index: 'not_analyzed'},
25-
popular_score: {type: 'double', index: 'not_analyzed'},
26-
score: {type: 'double', index: 'not_analyzed'},
27-
trending_score: {type: 'double', index: 'not_analyzed'},
28-
only_link: {type: 'string', index: 'not_analyzed'},
29-
link: {type: 'string', index: 'not_analyzed'},
30-
team: {type: 'multi_field', index: 'not_analyzed', fields: {
31-
name: {type: 'string', index: 'snowball'},
32-
slug: {type: 'string', boost: 50, index: 'snowball'},
33-
avatar: {type: 'string', index: 'not_analyzed'},
34-
profile_path: {type: 'string', index: 'not_analyzed'},
35-
hiring: {type: 'boolean', index: 'not_analyzed'}
36-
}},
37-
views_count: {type: 'integer', index: 'not_analyzed'},
38-
comments_count: {type: 'integer', index: 'not_analyzed'},
39-
best_stat: {type: 'multi_field', index: 'not_analyzed', fields: {
40-
name: {type: 'string', index: 'not_analyzed'},
41-
value: {type: 'integer', index: 'not_analyzed'},
42-
}},
43-
comments: {type: 'object', index: 'not_analyzed', properties: {
44-
title: {type: 'string', boost: 100, analyzer: 'snowball'},
45-
body: {type: 'string', boost: 80, analyzer: 'snowball'},
46-
likes: {type: 'integer', index: 'not_analyzed'}
47-
}},
48-
networks: {type: 'string', boost: 50, analyzer: 'comma'},
49-
upvoters: {type: 'integer', boost: 50, index: 'not_analyzed'},
50-
created_at: {type: 'date', boost: 10, index: 'not_analyzed'},
51-
featured: {type: 'boolean', index: 'not_analyzed'},
52-
flagged: {type: 'boolean', index: 'not_analyzed'},
53-
created_automagically: {type: 'boolean', index: 'not_analyzed'},
54-
reviewed: {type: 'boolean', index: 'not_analyzed'},
55-
user: {type: 'multi_field', index: 'not_analyzed', fields: {
56-
username: {type: 'string', boost: 40, index: 'not_analyzed'},
57-
name: {type: 'string', boost: 40, index: 'not_analyzed'},
58-
user_id: {type: 'integer', boost: 40, index: 'not_analyzed'},
59-
profile_path: {type: 'string', index: 'not_analyzed'},
60-
avatar: {type: 'string', index: 'not_analyzed'},
61-
about: {type: 'string', index: 'not_analyzed'},
62-
}}}}
46+
likes: {type: 'integer', index: 'not_analyzed'}
47+
}},
48+
networks: {type: 'string', boost: 50, analyzer: 'comma'},
49+
upvoters: {type: 'integer', boost: 50, index: 'not_analyzed'},
50+
created_at: {type: 'date', boost: 10, index: 'not_analyzed'},
51+
featured: {type: 'boolean', index: 'not_analyzed'},
52+
flagged: {type: 'boolean', index: 'not_analyzed'},
53+
created_automagically: {type: 'boolean', index: 'not_analyzed'},
54+
reviewed: {type: 'boolean', index: 'not_analyzed'},
55+
user: {type: 'multi_field', index: 'not_analyzed', fields: {
56+
username: {type: 'string', boost: 40, index: 'not_analyzed'},
57+
name: {type: 'string', boost: 40, index: 'not_analyzed'},
58+
user_id: {type: 'integer', boost: 40, index: 'not_analyzed'},
59+
profile_path: {type: 'string', index: 'not_analyzed'},
60+
avatar: {type: 'string', index: 'not_analyzed'},
61+
about: {type: 'string', index: 'not_analyzed'},
62+
}}}}
6363
end
6464
end

app/models/protip.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class Protip < ActiveRecord::Base
1010
extend FriendlyId
1111
friendly_id :slug_format, :use => :slugged
12-
12+
1313
include Featurable
1414
# TODO: Break out the various responsibilities on the Protip into modules/concerns.
1515

@@ -331,16 +331,16 @@ def valid_reviewers
331331
# Homepage 4.0 rewrite
332332
#######################
333333
#TODO REMOVE
334-
def deindex_search
335-
ProtipIndexer.new(self).remove
336-
end
337-
def index_search
338-
ProtipIndexer.new(self).store
339-
end
334+
def deindex_search
335+
ProtipIndexer.new(self).remove
336+
end
337+
def index_search
338+
ProtipIndexer.new(self).store
339+
end
340340

341-
def index_search_after_destroy
342-
self.tire.update_index
343-
end
341+
def index_search_after_destroy
342+
self.tire.update_index
343+
end
344344

345345

346346
def networks
@@ -954,11 +954,11 @@ def matching_jobs
954954
def to_html
955955
CFM::Markdown.render self.body
956956
end
957-
957+
958958
def slug_format
959959
"#{title}"
960960
end
961-
961+
962962
protected
963963
def check_links
964964
errors[:body] << "one or more of the links are invalid or not publicly reachable/require login" unless valid_links?
@@ -976,7 +976,7 @@ def adjust_like_value(user, like_value)
976976
def analyze_spam
977977
AnalyzeSpamJob.perform_async({ id: id, klass: self.class.name })
978978
end
979-
979+
980980
end
981981

982982
# == Schema Information

app/models/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def teams_being_followed
242242
end
243243

244244
def on_team?
245-
!team_document_id.nil?
245+
not team_document_id.nil?
246246
end
247247

248248
def team_member_of?(user)

app/views/protips/index.html.haml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@
106106

107107
%h2 Connections
108108
%ul.protips-grid.connections-list.cf
109+
- ap current_user
110+
- ap current_user.following_users
111+
109112
- following_users = current_user.following_users
110113
#x-following-users.hide{'data-users' => following_users.map(&:username)}
111114

0 commit comments

Comments
 (0)