diff --git a/app/assets/javascripts/initializers/initScrolling.js.erb b/app/assets/javascripts/initializers/initScrolling.js.erb index 901783156..53e566051 100644 --- a/app/assets/javascripts/initializers/initScrolling.js.erb +++ b/app/assets/javascripts/initializers/initScrolling.js.erb @@ -226,7 +226,7 @@ function paginate(tag, params, requiresApproval) { } else { searchHash.class_name = "Article"; searchHash["published_at[gte]"] = homeEl.dataset.articlesSince; - searchHash.sort_by = "positive_reactions_count"; + searchHash.sort_by = "public_reactions_count"; } // Brute force copying code from a utlity for quick fix diff --git a/app/assets/javascripts/initializers/initializeCommentsPage.js.erb b/app/assets/javascripts/initializers/initializeCommentsPage.js.erb index 62fde8dde..3086d5d5c 100644 --- a/app/assets/javascripts/initializers/initializeCommentsPage.js.erb +++ b/app/assets/javascripts/initializers/initializeCommentsPage.js.erb @@ -18,21 +18,21 @@ function initializeCommentsPage() { var responseObj = JSON.parse(ajaxReq.response); var reactions = responseObj.reactions; var allNodes = document.getElementsByClassName('single-comment-node'); - var positiveReactionCounts = responseObj.positive_reaction_counts; + var publicReactionCounts = responseObj.public_reaction_counts; for (var i = 0; i < reactions.length; i++) { var buttForComment = document.getElementById('button-for-comment-' + reactions[i].reactable_id); if (buttForComment) { buttForComment.classList.add('reacted'); } } - for (var i = 0; i < positiveReactionCounts.length; i++) { - var buttForComment = document.getElementById('button-for-comment-' + positiveReactionCounts[i].id); + for (var i = 0; i < publicReactionCounts.length; i++) { + var buttForComment = document.getElementById('button-for-comment-' + publicReactionCounts[i].id); if (buttForComment) { - if (positiveReactionCounts[i].count > 0) { - if (!document.getElementById('reactions-count-' + positiveReactionCounts[i].id)) { - buttForComment.innerHTML = buttForComment.innerHTML + "" + positiveReactionCounts[i].count + ''; + if (publicReactionCounts[i].count > 0) { + if (!document.getElementById('reactions-count-' + publicReactionCounts[i].id)) { + buttForComment.innerHTML = buttForComment.innerHTML + "" + publicReactionCounts[i].count + ''; } else { - document.getElementById('reactions-count-' + positiveReactionCounts[i].id).innerHTML = positiveReactionCounts[i].count; + document.getElementById('reactions-count-' + publicReactionCounts[i].id).innerHTML = publicReactionCounts[i].count; } } } diff --git a/app/assets/javascripts/utilities/buildArticleHTML.js.erb b/app/assets/javascripts/utilities/buildArticleHTML.js.erb index 5788a79d3..c8978f78b 100644 --- a/app/assets/javascripts/utilities/buildArticleHTML.js.erb +++ b/app/assets/javascripts/utilities/buildArticleHTML.js.erb @@ -51,7 +51,7 @@ function buildArticleHTML(article) { flareTag = "person" } - var rc = article.positive_reactions_count + var rc = article.public_reactions_count var reactionsCount = (rc || '0') var reactionsDisplay = ''; diff --git a/app/assets/javascripts/utilities/buildCommentHTML.js.erb b/app/assets/javascripts/utilities/buildCommentHTML.js.erb index 3e2abd549..295b06528 100644 --- a/app/assets/javascripts/utilities/buildCommentHTML.js.erb +++ b/app/assets/javascripts/utilities/buildCommentHTML.js.erb @@ -108,6 +108,6 @@ function reactions(comment) { return ''; + '+comment.public_reactions_count+''; } } diff --git a/app/controllers/api/v0/articles_controller.rb b/app/controllers/api/v0/articles_controller.rb index 5edc13aee..4b5a80544 100644 --- a/app/controllers/api/v0/articles_controller.rb +++ b/app/controllers/api/v0/articles_controller.rb @@ -76,7 +76,7 @@ module Api id user_id organization_id collection_id title description main_image published_at crossposted_at social_image cached_tag_list slug path canonical_url comments_count - positive_reactions_count created_at edited_at last_comment_at published + public_reactions_count created_at edited_at last_comment_at published updated_at video_thumbnail_url ].freeze private_constant :INDEX_ATTRIBUTES_FOR_SERIALIZATION @@ -89,7 +89,7 @@ module Api ME_ATTRIBUTES_FOR_SERIALIZATION = %i[ id user_id organization_id title description main_image published published_at cached_tag_list - slug path canonical_url comments_count positive_reactions_count + slug path canonical_url comments_count public_reactions_count page_views_count crossposted_at body_markdown updated_at ].freeze private_constant :ME_ATTRIBUTES_FOR_SERIALIZATION diff --git a/app/controllers/internal/articles_controller.rb b/app/controllers/internal/articles_controller.rb index 14468c62a..b6d93ee25 100644 --- a/app/controllers/internal/articles_controller.rb +++ b/app/controllers/internal/articles_controller.rb @@ -54,7 +54,7 @@ class Internal::ArticlesController < Internal::ApplicationController where("published_at > ? OR crossposted_at > ?", days_ago.days.ago, days_ago.days.ago). includes(:user). limited_columns_internal_select. - order("positive_reactions_count DESC"). + order("public_reactions_count DESC"). page(params[:page]). per(50) end @@ -64,7 +64,7 @@ class Internal::ArticlesController < Internal::ApplicationController where("published_at > ?", months_ago). includes(user: [:notes]). limited_columns_internal_select. - order("positive_reactions_count DESC"). + order("public_reactions_count DESC"). page(params[:page]). per(50) end diff --git a/app/controllers/internal/comments_controller.rb b/app/controllers/internal/comments_controller.rb index e7d07244c..488535529 100644 --- a/app/controllers/internal/comments_controller.rb +++ b/app/controllers/internal/comments_controller.rb @@ -6,7 +6,7 @@ class Internal::CommentsController < Internal::ApplicationController Comment. includes(:user). includes(:commentable). - order("positive_reactions_count DESC"). + order("public_reactions_count DESC"). where("created_at > ?", params[:state].split("-").last.to_i.days.ago). page(params[:page] || 1).per(50) else diff --git a/app/controllers/reactions_controller.rb b/app/controllers/reactions_controller.rb index f040b1aff..b8013dc61 100644 --- a/app/controllers/reactions_controller.rb +++ b/app/controllers/reactions_controller.rb @@ -10,7 +10,7 @@ class ReactionsController < ApplicationController id = params[:article_id] reactions = if session_current_user_id - Reaction.positive. + Reaction.public_category. where( reactable_id: id, reactable_type: "Article", @@ -24,20 +24,20 @@ class ReactionsController < ApplicationController else comments = Comment. where(commentable_id: params[:commentable_id], commentable_type: params[:commentable_type]). - select(%i[id positive_reactions_count]) + select(%i[id public_reactions_count]) reaction_counts = comments.map do |comment| - { id: comment.id, count: comment.positive_reactions_count } + { id: comment.id, count: comment.public_reactions_count } end reactions = if session_current_user_id comment_ids = reaction_counts.map { |rc| rc[:id] } - cached_user_positive_reactions(current_user).where(reactable_id: comment_ids) + cached_user_public_reactions(current_user).where(reactable_id: comment_ids) else Reaction.none end - result = { positive_reaction_counts: reaction_counts } + result = { public_reaction_counts: reaction_counts } end render json: { @@ -95,9 +95,9 @@ class ReactionsController < ApplicationController render json: { result: result, category: category } end - def cached_user_positive_reactions(user) - Rails.cache.fetch("cached_user_reactions-#{user.id}-#{user.positive_reactions_count}", expires_in: 24.hours) do - user.reactions.positive + def cached_user_public_reactions(user) + Rails.cache.fetch("cached_user_reactions-#{user.id}-#{user.public_reactions_count}", expires_in: 24.hours) do + user.reactions.public_category end end diff --git a/app/controllers/stories_controller.rb b/app/controllers/stories_controller.rb index 92306c899..7db08083d 100644 --- a/app/controllers/stories_controller.rb +++ b/app/controllers/stories_controller.rb @@ -1,7 +1,7 @@ class StoriesController < ApplicationController DEFAULT_HOME_FEED_ATTRIBUTES_FOR_SERIALIZATION = { only: %i[ - title path id user_id comments_count positive_reactions_count organization_id + title path id user_id comments_count public_reactions_count organization_id reading_time video_thumbnail_url video video_duration_in_minutes language experience_level_rating experience_level_rating_distribution cached_user cached_organization classified_listing_category_id @@ -319,7 +319,7 @@ class StoriesController < ApplicationController def stories_by_timeframe if %w[week month year infinity].include?(params[:timeframe]) @stories.where("published_at > ?", Timeframer.new(params[:timeframe]).datetime). - order("positive_reactions_count DESC") + order("public_reactions_count DESC") elsif params[:timeframe] == "latest" @stories.where("score > ?", -20).order("published_at DESC") else diff --git a/app/javascript/articles/__tests__/utilities/articleUtilities.js b/app/javascript/articles/__tests__/utilities/articleUtilities.js index 4616fc3c5..9add848b7 100644 --- a/app/javascript/articles/__tests__/utilities/articleUtilities.js +++ b/app/javascript/articles/__tests__/utilities/articleUtilities.js @@ -127,7 +127,7 @@ export const articleWithReactions = { published_at: '2020-03-19T10:04:15-05:00', readable_publish_date: 'February 18', top_comments: [], - positive_reactions_count: 232, + public_reactions_count: 232, }; export const articleWithComments = { @@ -169,7 +169,7 @@ export const articleWithComments = { profile_image_90: '/images/7.png', }, ], - positive_reactions_count: 428, + public_reactions_count: 428, comments_count: 213, }; @@ -311,7 +311,7 @@ export const userArticle = { export const featuredArticle = { ...article, main_image: '/images/onboarding-background.png', - positive_reactions_count: 428, + public_reactions_count: 428, comments_count: 213, }; diff --git a/app/javascript/articles/components/ReactionsCount.jsx b/app/javascript/articles/components/ReactionsCount.jsx index 80ab1db5a..f4672401e 100644 --- a/app/javascript/articles/components/ReactionsCount.jsx +++ b/app/javascript/articles/components/ReactionsCount.jsx @@ -3,7 +3,7 @@ import { articlePropTypes } from '../../common-prop-types'; import { Button } from '../../crayons/Button'; export const ReactionsCount = ({ article }) => { - const totalReactions = article.positive_reactions_count || 0; + const totalReactions = article.public_reactions_count || 0; const reactionsSVG = () => ( ?", 24).find_each do |comment| + Comment.where("public_reactions_count > ?", 24).find_each do |comment| message = "You're famous! [This is the comment](https://#{ApplicationConfig['APP_DOMAIN']}#{comment.path}) for which you are being recognized. 😄" achievement = BadgeAchievement.create( user_id: comment.user_id, diff --git a/app/labor/cache_buster.rb b/app/labor/cache_buster.rb index ad6cbd434..c07fca2c4 100644 --- a/app/labor/cache_buster.rb +++ b/app/labor/cache_buster.rb @@ -77,7 +77,7 @@ module CacheBuster end TIMEFRAMES.each do |timestamp, interval| if Article.published.where("published_at > ?", timestamp). - order("positive_reactions_count DESC").limit(3).pluck(:id).include?(article.id) + order("public_reactions_count DESC").limit(3).pluck(:id).include?(article.id) bust("/top/#{interval}") bust("/top/#{interval}?i=i") bust("/top/#{interval}/?i=i") @@ -100,7 +100,7 @@ module CacheBuster end TIMEFRAMES.each do |timestamp, interval| if Article.published.where("published_at > ?", timestamp).tagged_with(tag). - order("positive_reactions_count DESC").limit(3).pluck(:id).include?(article.id) + order("public_reactions_count DESC").limit(3).pluck(:id).include?(article.id) bust("/top/#{interval}") bust("/top/#{interval}?i=i") bust("/top/#{interval}/?i=i") diff --git a/app/labor/reading_list.rb b/app/labor/reading_list.rb index d5126d034..c20696179 100644 --- a/app/labor/reading_list.rb +++ b/app/labor/reading_list.rb @@ -14,7 +14,7 @@ class ReadingList end def cached_ids_of_articles - Rails.cache.fetch("reading_list_ids_of_articles_#{user.id}_#{user.positive_reactions_count}") do + Rails.cache.fetch("reading_list_ids_of_articles_#{user.id}_#{user.public_reactions_count}") do ids_of_articles end end diff --git a/app/labor/sticky_article_collection.rb b/app/labor/sticky_article_collection.rb index 073d0ef0a..d4a4a4d0b 100644 --- a/app/labor/sticky_article_collection.rb +++ b/app/labor/sticky_article_collection.rb @@ -23,7 +23,7 @@ class StickyArticleCollection def tag_articles @tag_articles ||= Article.published.tagged_with(article_tags, any: true). includes(:user). - where("positive_reactions_count > ? OR comments_count > ?", reaction_count_num, comment_count_num). + where("public_reactions_count > ? OR comments_count > ?", reaction_count_num, comment_count_num). where.not(id: article.id, user_id: article.user_id). where("featured_number > ?", 5.days.ago.to_i). order(Arel.sql("RANDOM()")). diff --git a/app/models/article.rb b/app/models/article.rb index 5b6f108eb..3ca64ae0b 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -119,7 +119,7 @@ class Article < ApplicationRecord scope :limited_column_select, lambda { select(:path, :title, :id, :published, - :comments_count, :positive_reactions_count, :cached_tag_list, + :comments_count, :public_reactions_count, :cached_tag_list, :main_image, :main_image_background_hex_color, :updated_at, :slug, :video, :user_id, :organization_id, :video_source_url, :video_code, :video_thumbnail_url, :video_closed_caption_track_url, :language, @@ -130,7 +130,7 @@ class Article < ApplicationRecord scope :limited_columns_internal_select, lambda { select(:path, :title, :id, :featured, :approved, :published, - :comments_count, :positive_reactions_count, :cached_tag_list, + :comments_count, :public_reactions_count, :cached_tag_list, :main_image, :main_image_background_hex_color, :updated_at, :boost_states, :video, :user_id, :organization_id, :video_source_url, :video_code, :video_thumbnail_url, :video_closed_caption_track_url, :social_image, @@ -157,7 +157,7 @@ class Article < ApplicationRecord case kind when "creation" then :created_at when "views" then :page_views_count - when "reactions" then :positive_reactions_count + when "reactions" then :public_reactions_count when "comments" then :comments_count when "published" then :published_at else @@ -339,7 +339,7 @@ class Article < ApplicationRecord private def search_score - calculated_score = hotness_score.to_i + ((comments_count * 3).to_i + positive_reactions_count.to_i * 300 * user.reputation_modifier * score.to_i) + calculated_score = hotness_score.to_i + ((comments_count * 3).to_i + public_reactions_count.to_i * 300 * user.reputation_modifier * score.to_i) calculated_score.to_i end diff --git a/app/models/concerns/reactable.rb b/app/models/concerns/reactable.rb index 7aefbdfaa..5b33c91c0 100644 --- a/app/models/concerns/reactable.rb +++ b/app/models/concerns/reactable.rb @@ -6,6 +6,6 @@ module Reactable end def sync_reactions_count - update_column(:positive_reactions_count, reactions.positive.size) + update_column(:public_reactions_count, reactions.public_category.size) end end diff --git a/app/models/podcast_episode.rb b/app/models/podcast_episode.rb index dbd84866c..f44580ba4 100644 --- a/app/models/podcast_episode.rb +++ b/app/models/podcast_episode.rb @@ -75,7 +75,6 @@ class PodcastEpisode < ApplicationRecord end alias hotness_score zero_method alias search_score zero_method - alias positive_reactions_count zero_method alias public_reactions_count zero_method def class_name diff --git a/app/models/reaction.rb b/app/models/reaction.rb index 28a5614f7..93c5d30fc 100644 --- a/app/models/reaction.rb +++ b/app/models/reaction.rb @@ -5,6 +5,7 @@ class Reaction < ApplicationRecord SEARCH_CLASS = Search::Reaction CATEGORIES = %w[like readinglist unicorn thinking hands thumbsdown vomit].freeze + PUBLIC_CATEGORIES = %w[like readinglist unicorn thinking hands].freeze REACTABLE_TYPES = %w[Comment Article User].freeze STATUSES = %w[valid invalid confirmed archived].freeze @@ -13,11 +14,11 @@ class Reaction < ApplicationRecord counter_culture :reactable, column_name: proc { |model| - model.points.positive? ? "positive_reactions_count" : "reactions_count" + PUBLIC_CATEGORIES.include?(model.category) ? "public_reactions_count" : "reactions_count" } counter_culture :user - scope :positive, -> { where("points > ?", 0) } + scope :public_category, -> { where(category: PUBLIC_CATEGORIES) } scope :readinglist, -> { where(category: "readinglist") } scope :for_articles, ->(ids) { where(reactable_type: "Article", reactable_id: ids) } scope :eager_load_serialized_data, -> { includes(:reactable, :user) } @@ -53,7 +54,7 @@ class Reaction < ApplicationRecord def cached_any_reactions_for?(reactable, user, category) class_name = reactable.class.name == "ArticleDecorator" ? "Article" : reactable.class.name - cache_name = "any_reactions_for-#{class_name}-#{reactable.id}-#{user.reactions_count}-#{user.positive_reactions_count}-#{category}" + cache_name = "any_reactions_for-#{class_name}-#{reactable.id}-#{user.reactions_count}-#{user.public_reactions_count}-#{category}" Rails.cache.fetch(cache_name, expires_in: 24.hours) do Reaction.where(reactable_id: reactable.id, reactable_type: class_name, user: user, category: category).any? end diff --git a/app/models/user.rb b/app/models/user.rb index c9d084a03..0c427ba9f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -143,7 +143,6 @@ class User < ApplicationRecord validate :can_send_confirmation_email validate :update_rate_limit - alias_attribute :positive_reactions_count, :reactions_count alias_attribute :public_reactions_count, :reactions_count alias_attribute :subscribed_to_welcome_notifications?, :welcome_notifications diff --git a/app/serializers/search/article_serializer.rb b/app/serializers/search/article_serializer.rb index 209d5d29d..377762fd5 100644 --- a/app/serializers/search/article_serializer.rb +++ b/app/serializers/search/article_serializer.rb @@ -7,7 +7,7 @@ module Search attributes :approved, :body_text, :class_name, :cloudinary_video_url, :comments_count, :experience_level_rating, :experience_level_rating_distribution, :featured, :featured_number, :hotness_score, :language, - :main_image, :path, :positive_reactions_count, :public_reactions_count, :published, + :main_image, :path, :public_reactions_count, :published, :published_at, :reactions_count, :reading_time, :score, :title # video_duration_in_minutes in Elasticsearch is mapped as an integer diff --git a/app/serializers/search/comment_serializer.rb b/app/serializers/search/comment_serializer.rb index 63a239641..944fe9be2 100644 --- a/app/serializers/search/comment_serializer.rb +++ b/app/serializers/search/comment_serializer.rb @@ -4,7 +4,7 @@ module Search attribute :id, &:search_id - attributes :path, :positive_reactions_count, :public_reactions_count + attributes :path, :public_reactions_count attribute :body_text, &:body_markdown attribute :class_name do |comment| diff --git a/app/serializers/search/podcast_episode_serializer.rb b/app/serializers/search/podcast_episode_serializer.rb index f90bd031e..c32a945ec 100644 --- a/app/serializers/search/podcast_episode_serializer.rb +++ b/app/serializers/search/podcast_episode_serializer.rb @@ -5,7 +5,7 @@ module Search attribute :id, &:search_id attributes :body_text, :class_name, :comments_count, :hotness_score, :path, - :positive_reactions_count, :public_reactions_count, :published, :published_at, :quote, + :public_reactions_count, :published, :published_at, :quote, :reactions_count, :search_score, :subtitle, :summary, :title, :website_url diff --git a/app/serializers/search/user_serializer.rb b/app/serializers/search/user_serializer.rb index c328fc1a1..84391e996 100644 --- a/app/serializers/search/user_serializer.rb +++ b/app/serializers/search/user_serializer.rb @@ -12,7 +12,6 @@ module Search :mostly_work_with, :name, :path, - :positive_reactions_count, :public_reactions_count, :profile_image_90, :reactions_count, diff --git a/app/serializers/webhook/article_serializer.rb b/app/serializers/webhook/article_serializer.rb index 5fe8ef721..6f9d7ad8a 100644 --- a/app/serializers/webhook/article_serializer.rb +++ b/app/serializers/webhook/article_serializer.rb @@ -4,7 +4,7 @@ module Webhook set_type :article attributes :title, :description, :readable_publish_date, :cached_tag_list, :cached_tag_list_array, - :slug, :path, :url, :comments_count, :positive_reactions_count, :body_markdown + :slug, :path, :url, :comments_count, :public_reactions_count, :body_markdown attribute :canonical_url, &:processed_canonical_url attribute :body_html, &:processed_html diff --git a/app/services/analytics_service.rb b/app/services/analytics_service.rb index aca9a0ce7..11146edfb 100644 --- a/app/services/analytics_service.rb +++ b/app/services/analytics_service.rb @@ -85,7 +85,7 @@ class AnalyticsService where("score > 0") @follow_data = Follow. where(followable_type: user_or_org.class.name, followable_id: user_or_org.id) - @reaction_data = Reaction.positive. + @reaction_data = Reaction.public_category. where(reactable_id: article_ids, reactable_type: "Article") @page_view_data = PageView.where(article_id: article_ids) diff --git a/app/services/article_api_index_service.rb b/app/services/article_api_index_service.rb index 5ae93671d..a5ec7428b 100644 --- a/app/services/article_api_index_service.rb +++ b/app/services/article_api_index_service.rb @@ -63,7 +63,7 @@ class ArticleApiIndexService articles.where(approved: true).order("featured_number DESC") elsif top.present? articles.where("published_at > ?", top.to_i.days.ago). - order("positive_reactions_count DESC") + order("public_reactions_count DESC") else articles.order("hotness_score DESC") end @@ -74,7 +74,7 @@ class ArticleApiIndexService def top_articles Article.published.includes(:user, :organization). where("published_at > ?", top.to_i.days.ago). - order("positive_reactions_count DESC"). + order("public_reactions_count DESC"). page(page).per(per_page || DEFAULT_PER_PAGE) end @@ -83,11 +83,11 @@ class ArticleApiIndexService articles = if state == "fresh" articles.where( - "positive_reactions_count < ? AND featured_number > ? AND score > ?", 2, 7.hours.ago.to_i, -2 + "public_reactions_count < ? AND featured_number > ? AND score > ?", 2, 7.hours.ago.to_i, -2 ) elsif state == "rising" articles.where( - "positive_reactions_count > ? AND positive_reactions_count < ? AND featured_number > ?", + "public_reactions_count > ? AND public_reactions_count < ? AND featured_number > ?", 19, 33, 3.days.ago.to_i ) else diff --git a/app/services/articles/analytics_updater.rb b/app/services/articles/analytics_updater.rb index 538357122..ceb60c5d4 100644 --- a/app/services/articles/analytics_updater.rb +++ b/app/services/articles/analytics_updater.rb @@ -23,7 +23,7 @@ module Articles def fetch_and_update_page_views_and_reaction_counts(qualified_articles) qualified_articles.each_slice(15) do |chunk| chunk.each do |article| - article.update_columns(previous_positive_reactions_count: article.positive_reactions_count) + article.update_columns(previous_public_reactions_count: article.public_reactions_count) # Notification.send_milestone_notification(type: "Reaction", article_id: article.id) # Notification.send_milestone_notification(type: "View", article_id: article.id) end @@ -41,7 +41,7 @@ module Articles def should_fetch(article) return true if @context == "force" - article.positive_reactions_count > article.previous_positive_reactions_count || occasionally_force_fetch? + article.public_reactions_count > article.previous_public_reactions_count || occasionally_force_fetch? end def occasionally_force_fetch? diff --git a/app/services/exporter/articles.rb b/app/services/exporter/articles.rb index e1a7a7f81..113718f4d 100644 --- a/app/services/exporter/articles.rb +++ b/app/services/exporter/articles.rb @@ -53,7 +53,7 @@ module Exporter main_image main_image_background_hex_color path - positive_reactions_count + public_reactions_count processed_html published published_from_feed diff --git a/app/services/exporter/comments.rb b/app/services/exporter/comments.rb index a794be17f..0b0bd9939 100644 --- a/app/services/exporter/comments.rb +++ b/app/services/exporter/comments.rb @@ -26,7 +26,7 @@ module Exporter edited_at id_code markdown_character_count - positive_reactions_count + public_reactions_count processed_html receive_notifications ] diff --git a/app/services/notifications/milestone/send.rb b/app/services/notifications/milestone/send.rb index 50d7dc85b..7884d32b8 100644 --- a/app/services/notifications/milestone/send.rb +++ b/app/services/notifications/milestone/send.rb @@ -58,7 +58,7 @@ module Notifications if type == "View" last_milestone_notification.blank? && article.page_views_count > @next_milestone elsif type == "Reaction" - last_milestone_notification.blank? && article.positive_reactions_count > @next_milestone + last_milestone_notification.blank? && article.public_reactions_count > @next_milestone end end @@ -69,7 +69,7 @@ module Notifications milestone_count = article.page_views_count when "Reaction" milestones = [64, 128, 256, 512, 1024, 2048, 4096, 8192] - milestone_count = article.positive_reactions_count + milestone_count = article.public_reactions_count end closest_number = milestones.min_by { |num| (milestone_count - num).abs } diff --git a/app/services/search/query_builders/feed_content.rb b/app/services/search/query_builders/feed_content.rb index 99027516c..988367e01 100644 --- a/app/services/search/query_builders/feed_content.rb +++ b/app/services/search/query_builders/feed_content.rb @@ -51,7 +51,6 @@ module Search flare_tag_hash main_image path - positive_reactions_count public_reactions_count published_at readable_publish_date_string diff --git a/app/services/search/user.rb b/app/services/search/user.rb index 29b55d65c..0e8961089 100644 --- a/app/services/search/user.rb +++ b/app/services/search/user.rb @@ -21,7 +21,7 @@ module Search "path" => source["path"], "id" => source["id"], "class_name" => "User", - "positive_reactions_count" => source["positive_reactions_count"], + "public_reactions_count" => source["public_reactions_count"], "comments_count" => source["comments_count"], "badge_achievements_count" => source["badge_achievements_count"], "last_comment_at" => source["last_comment_at"], diff --git a/app/services/suggester/articles/classic.rb b/app/services/suggester/articles/classic.rb index 73ae52a4c..9a0372850 100644 --- a/app/services/suggester/articles/classic.rb +++ b/app/services/suggester/articles/classic.rb @@ -29,7 +29,7 @@ module Suggester includes(:user). limited_column_select. where(featured: true). - where("positive_reactions_count > ?", MIN_REACTION_COUNT). + where("public_reactions_count > ?", MIN_REACTION_COUNT). where("published_at > ?", 10.months.ago). order(Arel.sql("RANDOM()")).pluck(:id) end diff --git a/app/services/suggester/articles/high_quality.rb b/app/services/suggester/articles/high_quality.rb index e3237a1a0..7804278d1 100644 --- a/app/services/suggester/articles/high_quality.rb +++ b/app/services/suggester/articles/high_quality.rb @@ -11,7 +11,7 @@ module Suggester Article.published.where(featured: true). includes(:user). limited_column_select. - where("positive_reactions_count > ?", MIN_HQ_REACTION_COUNT). + where("public_reactions_count > ?", MIN_HQ_REACTION_COUNT). where.not(id: @not_ids). order(Arel.sql("RANDOM()")). limit(num) diff --git a/app/services/suggester/users/sidebar.rb b/app/services/suggester/users/sidebar.rb index 576022fb3..0b0e2a888 100644 --- a/app/services/suggester/users/sidebar.rb +++ b/app/services/suggester/users/sidebar.rb @@ -10,7 +10,7 @@ module Suggester Rails.cache.fetch(generate_cache_name, expires_in: 120.hours) do reaction_count = Rails.env.production? ? 25 : 0 user_ids = Article.published.tagged_with([given_tag], any: true). - where("positive_reactions_count > ?", reaction_count). + where("public_reactions_count > ?", reaction_count). where("published_at > ?", 4.months.ago). where("user_id != ?", user.id). where.not(user_id: user.following_by_type("User")). diff --git a/app/views/additional_content_boxes/_article_content_area.html.erb b/app/views/additional_content_boxes/_article_content_area.html.erb index 33fa0f834..2d2e6008d 100644 --- a/app/views/additional_content_boxes/_article_content_area.html.erb +++ b/app/views/additional_content_boxes/_article_content_area.html.erb @@ -12,8 +12,8 @@ <%= article.description %>
- <% if article.positive_reactions_count > 0 %> - " alt="Reactions" /> <%= article.positive_reactions_count %> + <% if article.public_reactions_count > 0 %> + " alt="Reactions" /> <%= article.public_reactions_count %> <% end %> <% if article.comments_count > 0 %> " alt="Reactions" class="comments-bubble" /> <%= article.comments_count %> diff --git a/app/views/api/v0/articles/_article.json.jbuilder b/app/views/api/v0/articles/_article.json.jbuilder index 4d8d69ed7..30a67282a 100644 --- a/app/views/api/v0/articles/_article.json.jbuilder +++ b/app/views/api/v0/articles/_article.json.jbuilder @@ -10,11 +10,12 @@ json.extract!( :path, :url, :comments_count, - :positive_reactions_count, + :public_reactions_count, :collection_id, :published_timestamp, ) +json.positive_reactions_count article.public_reactions_count json.cover_image cloud_cover_url(article.main_image) json.social_image article_social_image_url(article) json.canonical_url article.processed_canonical_url diff --git a/app/views/api/v0/articles/me.json.jbuilder b/app/views/api/v0/articles/me.json.jbuilder index ff9754d47..e090d35d3 100644 --- a/app/views/api/v0/articles/me.json.jbuilder +++ b/app/views/api/v0/articles/me.json.jbuilder @@ -12,12 +12,13 @@ json.array! @articles do |article| :path, :url, :comments_count, - :positive_reactions_count, + :public_reactions_count, :page_views_count, :published_timestamp, :body_markdown, ) + json.positive_reactions_count article.public_reactions_count json.cover_image cloud_cover_url(article.main_image) json.tag_list article.cached_tag_list_array json.canonical_url article.processed_canonical_url diff --git a/app/views/api/v0/articles/onboarding.json.jbuilder b/app/views/api/v0/articles/onboarding.json.jbuilder index 52c9a9086..ce578dd28 100644 --- a/app/views/api/v0/articles/onboarding.json.jbuilder +++ b/app/views/api/v0/articles/onboarding.json.jbuilder @@ -6,7 +6,7 @@ json.array! @articles do |article| :description, :published_at, :comments_count, - :positive_reactions_count, + :public_reactions_count, ) json.tag_list article.cached_tag_list diff --git a/app/views/articles/_single_story.html.erb b/app/views/articles/_single_story.html.erb index 94ac6f2bd..d6868efa6 100644 --- a/app/views/articles/_single_story.html.erb +++ b/app/views/articles/_single_story.html.erb @@ -1,17 +1,17 @@
<% if featured == true %> -
- -
-
+
+ +
+
<% end %> <% if story.video.present? && story.video_thumbnail_url.present? %> - - - <%= story.video_duration_in_minutes %> - - + + + <%= story.video_duration_in_minutes %> + + <% end %>
@@ -19,9 +19,9 @@