Add watercooler as sidebar tag and watercooler flare (#3465)
* Add watercooler as sidebar tag and watercooler flare * Fix black box cached_tag_list_array check * Adjust blackbox spec
This commit is contained in:
parent
1fcd6bb77b
commit
966f48f9b6
6 changed files with 49 additions and 13 deletions
|
|
@ -1425,6 +1425,10 @@
|
|||
border: 0;
|
||||
}
|
||||
}
|
||||
.widget-subtext {
|
||||
text-align: center;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.widget-events-single-link {
|
||||
color: $black;
|
||||
font-weight: 500;
|
||||
|
|
|
|||
|
|
@ -4,14 +4,17 @@ class BlackBox
|
|||
usable_date = article.crossposted_at || article.published_at
|
||||
reaction_points = article.score
|
||||
super_super_recent_bonus = usable_date > 1.hour.ago ? 28 : 0
|
||||
super_recent_bonus = usable_date > 8.hours.ago ? 31 : 0
|
||||
recency_bonus = usable_date > 12.hours.ago ? 80 : 0
|
||||
today_bonus = usable_date > 26.hours.ago ? 395 : 0
|
||||
two_day_bonus = usable_date > 48.hours.ago ? 330 : 0
|
||||
four_day_bonus = usable_date > 96.hours.ago ? 330 : 0
|
||||
super_recent_bonus = usable_date > 8.hours.ago ? 81 : 0
|
||||
recency_bonus = usable_date > 12.hours.ago ? 280 : 0
|
||||
today_bonus = usable_date > 26.hours.ago ? 495 : 0
|
||||
two_day_bonus = usable_date > 48.hours.ago ? 430 : 0
|
||||
four_day_bonus = usable_date > 96.hours.ago ? 430 : 0
|
||||
if usable_date < 10.days.ago
|
||||
reaction_points /= 2 # Older posts should fade
|
||||
end
|
||||
if article.decorate.cached_tag_list_array.include?("watercooler")
|
||||
reaction_points = (reaction_points * 0.8).to_i # watercooler posts shouldn't get as much love in feed
|
||||
end
|
||||
function_caller.call("blackbox-production-articleHotness",
|
||||
{ article: article, user: article.user }.to_json).to_i +
|
||||
reaction_points + recency_bonus + super_recent_bonus + super_super_recent_bonus + today_bonus + two_day_bonus + four_day_bonus
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
class FlareTag
|
||||
FLARES = %w[explainlikeimfive
|
||||
jokes
|
||||
watercooler
|
||||
ama
|
||||
techtalks
|
||||
help
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@
|
|||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if Article.active_help.any? %>
|
||||
<div class="widget">
|
||||
<header>
|
||||
<a href="/t/help"><h4>#help</h4></a>
|
||||
|
|
@ -56,9 +55,9 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/help">ASK FOR HELP</a>
|
||||
<p class="widget-subtext"><em>Let's figure this out together.</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if Article.active_threads(["ama"], Timeframer.new(params[:timeframe]).datetime).any? %>
|
||||
<div class="widget">
|
||||
<header>
|
||||
|
|
@ -71,10 +70,10 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/ama">START AN "AMA"</a>
|
||||
<p class="widget-subtext"><em>Everybody has a story to tell.</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if Article.active_threads(["challenge"], Timeframer.new(params[:timeframe]).datetime).any? %>
|
||||
<div class="widget">
|
||||
<header>
|
||||
<a href="/t/challenge"><h4>#challenge</h4></a>
|
||||
|
|
@ -86,9 +85,9 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/challenge">CREATE A CHALLENGE</a>
|
||||
</div>
|
||||
<p class="widget-subtext"><em>Flex your skills, stay sharp.</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="widget">
|
||||
<header>
|
||||
<a href="/t/discuss"><h4>#discuss</h4></a>
|
||||
|
|
@ -100,6 +99,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/discuss">START A DISCUSSION</a>
|
||||
<p class="widget-subtext"><em>What does the community think?</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="widget">
|
||||
|
|
@ -113,7 +113,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/explainlikeimfive">ASK FOR AN EXPLANATION</a>
|
||||
</div>
|
||||
<p class="widget-subtext"><em>Need simplicity in your life?</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="widget">
|
||||
<header>
|
||||
|
|
@ -126,6 +127,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/healthydebate">START A DEBATE</a>
|
||||
<p class="widget-subtext"><em>We won't agree on everything.</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="widget">
|
||||
|
|
@ -139,6 +141,21 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/meta">START A META DISCUSSION</a>
|
||||
<p class="widget-subtext"><em>About DEV itself.</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="widget">
|
||||
<header>
|
||||
<a href="/t/watercooler"><h4>#watercooler</h4></a>
|
||||
</header>
|
||||
<div class="widget-body">
|
||||
<div class="widget-link-list">
|
||||
<% Article.active_threads(["watercooler"], Timeframer.new(params[:timeframe]).datetime).each do |plucked_article| %>
|
||||
<%= render "articles/widget_list_item", plucked_article: plucked_article, show_comment_count: true %>
|
||||
<% end %>
|
||||
</div>
|
||||
<a class="cta cta-button" href="/new/watercooler">GO OFF-TOPIC</a>
|
||||
<p class="widget-subtext"><em>Light and off-topic chitchat.</em></p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
</div>
|
||||
<%= javascript_pack_tag "listingForm", defer: true %>
|
||||
<div class="field">
|
||||
<%= form.label "location", "Location" %>
|
||||
<%= form.label "location", "Location (If applicable for events, etc.)" %>
|
||||
<%= form.text_field "location", placeholder: "32 characters max, plain text" %>
|
||||
</div>
|
||||
<div class="field">
|
||||
|
|
|
|||
|
|
@ -24,7 +24,18 @@ RSpec.describe BlackBox do
|
|||
# + score (99)
|
||||
# + value from the function caller (5)
|
||||
score = described_class.article_hotness_score(article, function_caller)
|
||||
expect(score).to eq(1298)
|
||||
expect(score).to eq(1848)
|
||||
end
|
||||
|
||||
it "returns the lower correct value if article tagged with watercooler" do
|
||||
article.update_column(:score, 99)
|
||||
article.update_column(:cached_tag_list, "hello, discuss, watercooler")
|
||||
allow(function_caller).to receive(:call).and_return(5)
|
||||
# recent bonuses (28 + 31 + 80 + 395 + 330 + 330 = 1194)
|
||||
# + score (99)
|
||||
# + value from the function caller (5)
|
||||
score = described_class.article_hotness_score(article, function_caller)
|
||||
expect(score).to be < 1840 # lower because watercooler tag
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue