From 966f48f9b6542ba5bb61a95ba68dcfefd18b52d6 Mon Sep 17 00:00:00 2001 From: Ben Halpern Date: Fri, 12 Jul 2019 14:24:33 -0400 Subject: [PATCH] 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 --- app/assets/stylesheets/articles.scss | 4 +++ app/black_box/black_box.rb | 13 +++++---- app/labor/flare_tag.rb | 1 + .../articles/_sidebar_additional.html.erb | 29 +++++++++++++++---- app/views/classified_listings/_form.html.erb | 2 +- spec/black_box/black_box_spec.rb | 13 ++++++++- 6 files changed, 49 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/articles.scss b/app/assets/stylesheets/articles.scss index d9fbef209..c7707ea01 100644 --- a/app/assets/stylesheets/articles.scss +++ b/app/assets/stylesheets/articles.scss @@ -1425,6 +1425,10 @@ border: 0; } } + .widget-subtext { + text-align: center; + font-size: 0.9em; + } .widget-events-single-link { color: $black; font-weight: 500; diff --git a/app/black_box/black_box.rb b/app/black_box/black_box.rb index 5ca5fb8e6..ab3641310 100644 --- a/app/black_box/black_box.rb +++ b/app/black_box/black_box.rb @@ -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 diff --git a/app/labor/flare_tag.rb b/app/labor/flare_tag.rb index f5451bce8..7dcec7b21 100644 --- a/app/labor/flare_tag.rb +++ b/app/labor/flare_tag.rb @@ -1,6 +1,7 @@ class FlareTag FLARES = %w[explainlikeimfive jokes + watercooler ama techtalks help diff --git a/app/views/articles/_sidebar_additional.html.erb b/app/views/articles/_sidebar_additional.html.erb index 814768d3c..59f779363 100644 --- a/app/views/articles/_sidebar_additional.html.erb +++ b/app/views/articles/_sidebar_additional.html.erb @@ -44,7 +44,6 @@ <% end %> - <% if Article.active_help.any? %>

#help

@@ -56,9 +55,9 @@ <% end %>
ASK FOR HELP +

Let's figure this out together.

- <% end %> <% if Article.active_threads(["ama"], Timeframer.new(params[:timeframe]).datetime).any? %>
@@ -71,10 +70,10 @@ <% end %>
START AN "AMA" +

Everybody has a story to tell.

<% end %> - <% if Article.active_threads(["challenge"], Timeframer.new(params[:timeframe]).datetime).any? %>

#challenge

@@ -86,9 +85,9 @@ <% end %>
CREATE A CHALLENGE - +

Flex your skills, stay sharp.

+ - <% end %>

#discuss

@@ -100,6 +99,7 @@ <% end %>
START A DISCUSSION +

What does the community think?

@@ -113,7 +113,8 @@ <% end %>
ASK FOR AN EXPLANATION - +

Need simplicity in your life?

+
@@ -126,6 +127,7 @@ <% end %>
START A DEBATE +

We won't agree on everything.

@@ -139,6 +141,21 @@ <% end %>
START A META DISCUSSION +

About DEV itself.

+ + +
+
+

#watercooler

+
+
+ + GO OFF-TOPIC +

Light and off-topic chitchat.

<% end %> diff --git a/app/views/classified_listings/_form.html.erb b/app/views/classified_listings/_form.html.erb index c50bddb0c..b5b4b2e35 100644 --- a/app/views/classified_listings/_form.html.erb +++ b/app/views/classified_listings/_form.html.erb @@ -56,7 +56,7 @@ <%= javascript_pack_tag "listingForm", defer: true %>
- <%= form.label "location", "Location" %> + <%= form.label "location", "Location (If applicable for events, etc.)" %> <%= form.text_field "location", placeholder: "32 characters max, plain text" %>
diff --git a/spec/black_box/black_box_spec.rb b/spec/black_box/black_box_spec.rb index f4302ce2e..7ac07ac27 100644 --- a/spec/black_box/black_box_spec.rb +++ b/spec/black_box/black_box_spec.rb @@ -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