Skip to content

Commit 71083fc

Browse files
Expand Featureable to all Tools (#4094)
This adds `featured_status` and `featured_at` to tables for tools that didn't have it: - logos - podcasts - episodes - journals - videos
1 parent 7bac523 commit 71083fc

10 files changed

+94
-48
lines changed

app/lib/feature_flag.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# TODO: delete this file
12
# Start your Rails server with this ENV var:
23
# TWO_POINT_OH_YEAH=true bundle exec rails server
34
#

app/models/book.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Book < ApplicationRecord
22
include MultiPageTool
3-
include Featureable
43

54
def ask_for_donation?
65
downloads_available?

app/models/concerns/featureable.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module Featureable
22
extend ActiveSupport::Concern
33

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

109
module ClassMethods
1110
def for_index fallback_sort: { title: :asc }, fallback_locale: 'en'

app/models/episode.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Episode < ApplicationRecord
22
include Name
3+
include Featureable
34
include Publishable
45

56
belongs_to :podcast

app/models/issue.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Issue < ApplicationRecord
22
include MultiPageTool
3-
include Featureable
43

54
belongs_to :journal
65

app/models/logo.rb

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
class Logo < ApplicationRecord
22
include Tool
3+
include Featureable
4+
35
has_one_attached :image_jpg, dependent: :destroy
46
has_one_attached :image_png, dependent: :destroy
57
has_one_attached :image_pdf, dependent: :destroy

app/models/podcast.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Podcast < ApplicationRecord
22
include Name
3+
include Featureable
34

45
has_many :episodes, dependent: :destroy
56

app/models/video.rb

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class Video < ApplicationRecord
22
include Tool
3+
include Featureable
34

45
has_one_attached :image_poster_frame
56

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
class AddFeaturedToAllTools < ActiveRecord::Migration[7.2]
2+
def change
3+
# logos
4+
change_table :logos, bulk: true do |t|
5+
t.boolean :featured_status, default: false, null: false
6+
t.datetime :featured_at, precision: nil
7+
end
8+
9+
# podcasts
10+
change_table :podcasts, bulk: true do |t|
11+
t.boolean :featured_status, default: false, null: false
12+
t.datetime :featured_at, precision: nil
13+
end
14+
15+
# episodes
16+
change_table :episodes, bulk: true do |t|
17+
t.boolean :featured_status, default: false, null: false
18+
t.datetime :featured_at, precision: nil
19+
end
20+
21+
# journals
22+
change_table :journals, bulk: true do |t|
23+
t.boolean :featured_status, default: false, null: false
24+
t.datetime :featured_at, precision: nil
25+
end
26+
27+
# videos
28+
change_table :videos, bulk: true do |t|
29+
t.boolean :featured_status, default: false, null: false
30+
t.datetime :featured_at, precision: nil
31+
end
32+
end
33+
end

0 commit comments

Comments
 (0)