diff --git a/app/controllers/admin/articles_controller.rb b/app/controllers/admin/articles_controller.rb index 39bcc7c79..5c8793436 100644 --- a/app/controllers/admin/articles_controller.rb +++ b/app/controllers/admin/articles_controller.rb @@ -11,8 +11,6 @@ module Admin body_markdown approved email_digest_eligible - boosted_additional_articles - boosted_dev_digest_email main_image_background_hex_color featured_number user_id @@ -26,8 +24,6 @@ module Admin when /top-/ months_ago = params[:state].split("-")[1].to_i.months.ago @articles = articles_top(months_ago) - when "boosted-additional-articles" - @articles = articles_boosted_additional when "chronological" @articles = articles_chronological else @@ -79,15 +75,6 @@ module Admin .per(50) end - def articles_boosted_additional - Article.boosted_via_additional_articles - .includes(:user) - .limited_columns_internal_select - .order(published_at: :desc) - .page(params[:page]) - .per(100) - end - def articles_chronological Article.published .includes(user: [:notes]) diff --git a/app/decorators/article_decorator.rb b/app/decorators/article_decorator.rb index acf0254bf..2007e9a5f 100644 --- a/app/decorators/article_decorator.rb +++ b/app/decorators/article_decorator.rb @@ -39,18 +39,6 @@ class ArticleDecorator < ApplicationDecorator end end - def internal_utm_params(place = "additional_box") - org_slug = organization&.slug - - campaign = if boosted_additional_articles - "#{org_slug}_boosted" - else - "regular" - end - - "?utm_source=#{place}&utm_medium=internal&utm_campaign=#{campaign}&booster_org=#{org_slug}" - end - def published_at_int published_at.to_i end diff --git a/app/models/article.rb b/app/models/article.rb index a1b3711c3..67063e3bd 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -54,7 +54,6 @@ class Article < ApplicationRecord validates :body_markdown, bytesize: { maximum: 800.kilobytes, too_long: "is too long." } validates :body_markdown, length: { minimum: 0, allow_nil: false } validates :body_markdown, uniqueness: { scope: %i[user_id title] } - validates :boost_states, presence: true validates :cached_tag_list, length: { maximum: 126 } validates :canonical_url, uniqueness: { allow_nil: true, scope: :published, message: UNIQUE_URL_ERROR }, @@ -250,28 +249,20 @@ class Article < ApplicationRecord :video, :user_id, :organization_id, :video_source_url, :video_code, :video_thumbnail_url, :video_closed_caption_track_url, :experience_level_rating, :experience_level_rating_distribution, :cached_user, :cached_organization, - :published_at, :crossposted_at, :boost_states, :description, :reading_time, :video_duration_in_seconds, + :published_at, :crossposted_at, :description, :reading_time, :video_duration_in_seconds, :last_comment_at) } scope :limited_columns_internal_select, lambda { select(:path, :title, :id, :featured, :approved, :published, :comments_count, :public_reactions_count, :cached_tag_list, - :main_image, :main_image_background_hex_color, :updated_at, :boost_states, + :main_image, :main_image_background_hex_color, :updated_at, :video, :user_id, :organization_id, :video_source_url, :video_code, :video_thumbnail_url, :video_closed_caption_track_url, :social_image, :published_from_feed, :crossposted_at, :published_at, :featured_number, :created_at, :body_markdown, :email_digest_eligible, :processed_html, :co_author_ids) } - scope :boosted_via_additional_articles, lambda { - where("boost_states ->> 'boosted_additional_articles' = 'true'") - } - - scope :boosted_via_dev_digest_email, lambda { - where("boost_states ->> 'boosted_dev_digest_email' = 'true'") - } - scope :sorting, lambda { |value| value ||= "creation-desc" kind, dir = value.split("-") @@ -308,12 +299,6 @@ class Article < ApplicationRecord scope :eager_load_serialized_data, -> { includes(:user, :organization, :tags) } - store_attributes :boost_states do - boosted_additional_articles Boolean, default: false - boosted_dev_digest_email Boolean, default: false - boosted_additional_tags String, default: "" - end - def self.seo_boostable(tag = nil, time_ago = 18.days.ago) # Time ago sometimes returns this phrase instead of a date time_ago = 5.days.ago if time_ago == "latest" diff --git a/app/views/admin/articles/_individual_article.html.erb b/app/views/admin/articles/_individual_article.html.erb index b183adba2..2ac2b2d86 100644 --- a/app/views/admin/articles/_individual_article.html.erb +++ b/app/views/admin/articles/_individual_article.html.erb @@ -24,10 +24,8 @@
Edit - - Manage User - + <% if decorated_article.pinned? %> <%= link_to( "Unpin Post", @@ -141,9 +139,6 @@
- <%= f.check_box :boosted_additional_articles, id: "boosted_additional_articles-#{article.id}" %> - -
<%= check_box_tag :pinned, "1", decorated_article.pinned?, name: "article[pinned]", @@ -160,23 +155,5 @@
<% end %> - - <% if article.boosted_dev_digest_email %> -

- <% phrase = "#{article.path}?booster_org=#{article.organization&.slug || 'generic'}" %> - BOOSTED IN <%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).size %> EMAILS -
- BOOSTED IN - <%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where("sent_at > ?", 1.week.ago).size %> - EMAILS IN THE PAST WEEK -

- BOOSTED IN - <%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where.not(opened_at: nil).size %> - OPENED EMAILS -
- BOOSTED IN - <%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where.not(opened_at: nil).where("sent_at > ?", 1.week.ago).size %> - OPENED EMAILS IN THE PAST WEEK - <% end %> diff --git a/app/views/admin/articles/index.html.erb b/app/views/admin/articles/index.html.erb index 3f0ad5265..f1b1c3b4d 100644 --- a/app/views/admin/articles/index.html.erb +++ b/app/views/admin/articles/index.html.erb @@ -18,11 +18,6 @@ href="<%= admin_articles_path(state: :chronological) %>" class="nav-link <%= "active" if params[:state] == "chronological" %>">Chronological - <% if params[:state] && params[:state].include?("top-") && params[:state] != "top-3" && params[:state] != "top-6" %>

diff --git a/db/migrate/20211007172232_drop_boost_states_from_articles.rb b/db/migrate/20211007172232_drop_boost_states_from_articles.rb new file mode 100644 index 000000000..22d85936e --- /dev/null +++ b/db/migrate/20211007172232_drop_boost_states_from_articles.rb @@ -0,0 +1,7 @@ +class DropBoostStatesFromArticles < ActiveRecord::Migration[6.1] + def change + safety_assured do + remove_column :articles, :boost_states, :jsonb + end + end +end diff --git a/db/schema.rb b/db/schema.rb index c827b80b0..368725edb 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_30_062627) do +ActiveRecord::Schema.define(version: 2021_10_07_172232) do # These are extensions that must be enabled in order to support this database enable_extension "citext" @@ -86,7 +86,6 @@ ActiveRecord::Schema.define(version: 2021_08_30_062627) do t.boolean "archived", default: false t.text "body_html" t.text "body_markdown" - t.jsonb "boost_states", default: {}, null: false t.text "cached_organization" t.string "cached_tag_list" t.text "cached_user" @@ -154,7 +153,6 @@ ActiveRecord::Schema.define(version: 2021_08_30_062627) do t.string "video_state" t.string "video_thumbnail_url" t.index "user_id, title, digest(body_markdown, 'sha512'::text)", name: "index_articles_on_user_id_and_title_and_digest_body_markdown", unique: true - t.index ["boost_states"], name: "index_articles_on_boost_states", using: :gin t.index ["cached_tag_list"], name: "index_articles_on_cached_tag_list", opclass: :gin_trgm_ops, using: :gin t.index ["canonical_url"], name: "index_articles_on_canonical_url", unique: true, where: "(published IS TRUE)" t.index ["collection_id"], name: "index_articles_on_collection_id" diff --git a/spec/decorators/article_decorator_spec.rb b/spec/decorators/article_decorator_spec.rb index d894e09bf..4b2d17f6a 100644 --- a/spec/decorators/article_decorator_spec.rb +++ b/spec/decorators/article_decorator_spec.rb @@ -114,52 +114,6 @@ RSpec.describe ArticleDecorator, type: :decorator do end end - describe "internal_utm_params" do - it "returns utm params for a boosted article" do - article.boosted_additional_articles = true - - params = ["utm_medium=internal", "utm_campaign=_boosted", "booster_org="] - expected_result = "?utm_source=additional_box&#{params.join('&')}" - expect(article.decorate.internal_utm_params).to eq(expected_result) - end - - it "returns utm params for a boosted article belonging to an organization" do - article.boosted_additional_articles = true - article.organization = organization - - slug = organization.slug - params = ["utm_medium=internal", "utm_campaign=#{slug}_boosted", "booster_org=#{slug}"] - expected_result = "?utm_source=additional_box&#{params.join('&')}" - expect(article.decorate.internal_utm_params).to eq(expected_result) - end - - it "returns utm params for a regular article" do - article.boosted_additional_articles = false - - params = ["utm_medium=internal", "utm_campaign=regular", "booster_org="] - expected_result = "?utm_source=additional_box&#{params.join('&')}" - expect(article.decorate.internal_utm_params).to eq(expected_result) - end - - it "returns utm params for a regular article belonging to an organization" do - article.boosted_additional_articles = false - article.organization = organization - - slug = organization.slug - params = ["utm_medium=internal", "utm_campaign=regular", "booster_org=#{slug}"] - expected_result = "?utm_source=additional_box&#{params.join('&')}" - expect(article.decorate.internal_utm_params).to eq(expected_result) - end - - it "returns utm params for an article in a different place" do - article.boosted_additional_articles = false - - params = ["utm_medium=internal", "utm_campaign=regular", "booster_org="] - expected_result = "?utm_source=homepage&#{params.join('&')}" - expect(article.decorate.internal_utm_params("homepage")).to eq(expected_result) - end - end - describe "#published_at_int" do it "returns the publication date as an integer" do expect(article.decorate.published_at_int).to eq(article.published_at.to_i) diff --git a/spec/models/article_spec.rb b/spec/models/article_spec.rb index b8520d3a0..562f4e6df 100644 --- a/spec/models/article_spec.rb +++ b/spec/models/article_spec.rb @@ -39,7 +39,6 @@ RSpec.describe Article, type: :model do it { is_expected.to validate_length_of(:cached_tag_list).is_at_most(126) } it { is_expected.to validate_length_of(:title).is_at_most(128) } - it { is_expected.to validate_presence_of(:boost_states) } it { is_expected.to validate_presence_of(:comments_count) } it { is_expected.to validate_presence_of(:positive_reactions_count) } it { is_expected.to validate_presence_of(:previous_public_reactions_count) }