Permalink
Browse files

Merge remote-tracking branch 'origin/dev' into waiting-users

  • Loading branch information...
2 parents b6c13ec + 7a88c8f commit 6f829ca2bd2b33702040eaed092734cff2ccbd57 Alex Bredariol Grilo committed Nov 29, 2011
View
@@ -15,6 +15,7 @@ log/
tmp/**/*
dump
*.swp
+*.swo
*~
vendor/cache
public/stylesheets/compiled
@@ -81,6 +81,7 @@ def signup_with_provider
end
if user = User.create_with_provider(auth_hash)
+ current_group.add_member(user)
invitation_type = session['invitation_type']
ref = session['invitation_id'] if invitation_type == "UrlInvitation"
slug = session["invitation_id"] if invitation_type == "GroupInvitation"
@@ -54,12 +54,7 @@ def show
@topic.indirect_question_lists.paginate(:per_page => 6,
:order => :created_at.desc)
- ni_sr = ab_test(:news_items_search_results_helpers)
- if ni_sr == :answer
- options = {:news_update_entry_type => {:$ne => "SearchResult"}}
- else
- options = {:news_update_entry_type => {:$ne => "Answer"}}
- end
+ options = {:news_update_entry_type => {:$ne => "Answer"}}
@news_items = NewsItem.paginate({
:recipient_id => @topic.id,
@@ -144,15 +144,7 @@ def show
@order_info = {:will_sort => false}
- # A/B test for news items
- ni_sr = ab_test(:news_items_search_results_helpers)
- ni_sr = :answer
- if ni_sr == :answer
- options = {:entry_type => {:$ne => "SearchResult"}}
- else
- options = {:entry_type => {:$ne => "Answer"}}
- end
-
+ options = {:entry_type => {:$ne => "Answer"}}
@page = params[:page] || 1
@items = @user.news_updates.paginate(options.merge(
@@ -26,16 +26,11 @@ def landing
end
def home
- ni_sr = ab_test(:news_items_search_results_helpers)
- if ni_sr == :answer
- options = {:news_update_entry_type => {:$ne => "SearchResult"}}
- else
- options = {:news_update_entry_type => {:$ne => "Answer"}}
- end
+ @news_items = filter_news_items(:news_update_entry_type => "Question")
- @news_items = filter_news_items(options)
-
- @questions = Question.latest.limit(10) || [] if @news_items.empty?
+ if @news_items.empty?
+ @questions = Question.sort(:activity_at.desc).limit(10) || []
+ end
@getting_started = Answer.find_by_id("4d42bebf79de4f262d000e4b")
if %w[facebook twitter].include?(params[:shared_url_invitation])
@@ -124,7 +119,7 @@ def filter_news_items(options = {})
NewsItem.paginate({
:recipient_id => current_user.id, :recipient_type => "User",
:per_page => 15, :page => params[:page] || 1,
- :order => :created_at.desc, :visible => true}.merge(options))
+ :order => :entry_activity_at.desc, :visible => true}.merge(options))
end
def calculate_counts
View
@@ -169,12 +169,12 @@ def add_member(user, role = 'user')
end
def users(conditions = {})
- User.all(conditions.merge("membership_list.#{self.id}.reputation" => {:$exists => true}))
+ User.all(conditions)
end
alias_method :members, :users
def paginate_users(conditions = {})
- User.paginate(conditions.merge("membership_list.#{self.id}.reputation" => {:$exists => true}))
+ User.paginate(conditions)
end
def pending?
View
@@ -591,6 +591,16 @@ def topic_followers_count
@topic_followers_count ||= topics.map(&:followers_count).inject(0, :+)
end
+ def unseen_search_results_count(user_id)
+ uqi = UserQuestionInfo.find_by_user_id_and_question_id(user_id, self.id)
+ if uqi && uqi.last_visited_at
+ self.search_results.count(:created_at.gt => uqi.last_visited_at,
+ :user_id.ne => user_id)
+ else
+ self.search_results.count
+ end
+ end
+
protected
def delete_answers
Answer.destroy_all(:question_id => self.id)
View
@@ -167,8 +167,8 @@ def update_related_topics!
self.find_related_topics
# if an error happens during set, set will return a Hash with it
- errors_ids = self.set(:related_topic_ids, self.related_topics_id)
- errors_count = self.set(:related_topics_count, self.related_topics_count)
+ errors_ids = self.set(:related_topic_ids => self.related_topics_id)
+ errors_count = self.set(:related_topics_count => self.related_topics_count)
# only return true if both fields could be updated properly
!(errors_ids.is_a?(Hash) || errors_count.is_a?(Hash))
@@ -2,7 +2,8 @@
.loader{:style => 'display: none;'}
= waiting_tag
- if logged_in? && !@question.closed
- - if ab_test(:link_only_answer_form) == :link_only_answer_form
+ -# hardcoded to false to use the old-style answer form:
+ - if false
= form_for(@search_result,
:url => question_search_results_path(@question.id, :format => :js),
:html => { :class => 'form bp',
@@ -30,8 +30,11 @@
.metadata
= t("time.ago", :time => time_ago_in_words(last_target.updated_at))
\|
- = format_number(question.search_results.count)
- = t(:answer_count, :scope => "activerecord.models", :count => question.search_results.count)
+ - if logged_in?
+ = t(:new_answer_count, :scope => "welcome.news_item.question", :count => question.unseen_search_results_count(current_user.id))
+ - else
+ = format_number(question.search_results.count)
+ = t(:answer_count, :scope => "activerecord.models", :count => question.search_results.count)
= render :partial => 'shared/stats_follow', :locals => { :question => question }
.clear
- else
@@ -2,7 +2,8 @@
= f.hidden_field(:group_id, :value => group_id)
= f.hidden_field(:user_id, :value => user_id)
-- if ab_test(:link_only_answer_form) == :link_only_answer_form
+-# hardcoded to false to use the old-style answer form:
+- if false
#search_result_area
= f.text_field(:url, :type => :url, :class => "link_only_answer_form",
:placeholder => t("search_results.add_link"))
@@ -7,7 +7,7 @@
.user_info
.user_title
.arrow
- = link_to(nil, '#', :class => 'down-arrow')
+ = link_to('', '#', :class => 'down-arrow')
.user_name
= link_to(truncate(h(short_name(current_user)), :length => 16),
user_path(current_user))
@@ -33,7 +33,10 @@
.metadata
= t("time.ago", :time => time_ago_in_words(entry.created_at))
\|
- = format_number(question.search_results.count)
- = t(:answer_count, :scope => "activerecord.models", :count => question.search_results.count)
+ - if logged_in?
+ = t(:new_answer_count, :scope => "welcome.news_item.question", :count => question.unseen_search_results_count(current_user.id))
+ - else
+ = format_number(question.search_results.count)
+ = t(:answer_count, :scope => "activerecord.models", :count => question.search_results.count)
= render :partial => 'shared/stats_follow', :locals => { :question => question }
.clear
@@ -36,6 +36,10 @@ en:
created: Question added to topic %{origin}.
user:
created: "%{origin} added a question."
+ new_answer_count:
+ zero: "no new answers"
+ one: "%{count} new answer"
+ other: "%{count} new answers"
searchresult:
topic:
created: Answer to %{question} added to %{origin}.
@@ -40,6 +40,10 @@ pt-BR:
created: "Pergunta adicionada ao tópico %{origin}."
user:
created: "%{origin} adicionou uma pergunta."
+ new_answer_count:
+ zero: "nenhuma nova resposta"
+ one: "%{count} nova resposta"
+ other: "%{count} novas respostas"
searchresult:
topic:
created: "Resposta para %{question} adicionadaa ao tópico %{origin}."
@@ -1,5 +0,0 @@
-ab_test 'Link only answer form' do
- alternatives :full_answer_form, :link_only_answer_form
- metrics :new_search_result
- identify { |c| c.identifier(:exclude_guests => true) }
-end
@@ -1,5 +0,0 @@
-ab_test 'News item search results helpers' do
- alternatives :answer, :search_results
- metrics :commented, :voted, :used_today
- identify { |c| c.identifier }
-end
@@ -48,6 +48,7 @@ namespace :news_items do
activity_at_hash[nu.id] = nu.entry.activity_at
end
NewsItem.find_each(:batch_size => 1_000,
+ :entry_activity_at => nil,
:news_update_entry_type => "Question") do |ni|
print '.'
ni.set(:entry_activity_at => activity_at_hash[ni.news_update_id])

0 comments on commit 6f829ca

Please sign in to comment.