Skip to content

Commit

Permalink
Expand Featureable to all Tools (#4094)
Browse files Browse the repository at this point in the history
This adds `featured_status` and `featured_at` to tables for tools that
didn't have it:

- logos
- podcasts
- episodes
- journals
- videos
  • Loading branch information
veganstraightedge authored Nov 26, 2024
1 parent 7bac523 commit 71083fc
Show file tree
Hide file tree
Showing 10 changed files with 94 additions and 48 deletions.
1 change: 1 addition & 0 deletions app/lib/feature_flag.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# TODO: delete this file
# Start your Rails server with this ENV var:
# TWO_POINT_OH_YEAH=true bundle exec rails server
#
Expand Down
1 change: 0 additions & 1 deletion app/models/book.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Book < ApplicationRecord
include MultiPageTool
include Featureable

def ask_for_donation?
downloads_available?
Expand Down
9 changes: 4 additions & 5 deletions app/models/concerns/featureable.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module Featureable
extend ActiveSupport::Concern

# TEMP: re-enable and expand coverage to include Journal, Issue, et al
# included do
# scope :featured, -> { where.not(featured_at: nil) }
# before_save :update_featured_at
# end
included do
scope :featured, -> { where.not(featured_at: nil) }
before_save :update_featured_at
end

module ClassMethods
def for_index fallback_sort: { title: :asc }, fallback_locale: 'en'
Expand Down
1 change: 1 addition & 0 deletions app/models/episode.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Episode < ApplicationRecord
include Name
include Featureable
include Publishable

belongs_to :podcast
Expand Down
1 change: 0 additions & 1 deletion app/models/issue.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Issue < ApplicationRecord
include MultiPageTool
include Featureable

belongs_to :journal

Expand Down
2 changes: 2 additions & 0 deletions app/models/logo.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
class Logo < ApplicationRecord
include Tool
include Featureable

has_one_attached :image_jpg, dependent: :destroy
has_one_attached :image_png, dependent: :destroy
has_one_attached :image_pdf, dependent: :destroy
Expand Down
1 change: 1 addition & 0 deletions app/models/podcast.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Podcast < ApplicationRecord
include Name
include Featureable

has_many :episodes, dependent: :destroy

Expand Down
1 change: 1 addition & 0 deletions app/models/video.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class Video < ApplicationRecord
include Tool
include Featureable

has_one_attached :image_poster_frame

Expand Down
33 changes: 33 additions & 0 deletions db/migrate/20241125231604_add_featured_to_all_tools.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
class AddFeaturedToAllTools < ActiveRecord::Migration[7.2]
def change
# logos
change_table :logos, bulk: true do |t|
t.boolean :featured_status, default: false, null: false
t.datetime :featured_at, precision: nil
end

# podcasts
change_table :podcasts, bulk: true do |t|
t.boolean :featured_status, default: false, null: false
t.datetime :featured_at, precision: nil
end

# episodes
change_table :episodes, bulk: true do |t|
t.boolean :featured_status, default: false, null: false
t.datetime :featured_at, precision: nil
end

# journals
change_table :journals, bulk: true do |t|
t.boolean :featured_status, default: false, null: false
t.datetime :featured_at, precision: nil
end

# videos
change_table :videos, bulk: true do |t|
t.boolean :featured_status, default: false, null: false
t.datetime :featured_at, precision: nil
end
end
end
Loading

0 comments on commit 71083fc

Please sign in to comment.