Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def today

def display_banner
# Cache banners to avoid repeated queries during page render
@banners ||= Banner.published.select("id, content").to_a
@banners ||= Banner.active.select("id, content").to_a
return if @banners.empty?

safe_content_array = @banners.map { |banner|
Expand Down
6 changes: 6 additions & 0 deletions app/models/banner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ class Banner < ApplicationRecord
def name
content.truncate(50)
end

scope :active, -> {
where(show: true)
.where("started_at IS NULL OR started_at <= ?", Time.current)
.where("ended_at IS NULL OR ended_at >= ?", Time.current)
}
end
6 changes: 6 additions & 0 deletions db/migrate/20260305105227_add_timeto_banner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class AddTimetoBanner < ActiveRecord::Migration[8.1]
def change
add_column :banners, :started_at, :datetime
add_column :banners, :ended_at, :datetime
end
end
81 changes: 78 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@

create_table "ahoy_events", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "name"
t.json "properties"
t.text "properties"
t.bigint "resource_id"
t.string "resource_type"
t.datetime "time"
Expand Down Expand Up @@ -210,11 +210,21 @@
end

create_table "banners", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
<<<<<<< HEAD
t.text "content"
t.datetime "created_at", precision: nil, null: false
t.integer "created_by_id"
t.boolean "published", default: false, null: false
t.boolean "show"
=======
t.text "content", size: :medium
t.datetime "created_at", precision: nil, null: false
t.integer "created_by_id"
t.datetime "ended_at"
t.boolean "published", default: false, null: false
t.boolean "show"
t.datetime "started_at"
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.datetime "updated_at", precision: nil, null: false
t.integer "updated_by_id"
t.index ["created_by_id"], name: "index_banners_on_created_by_id"
Expand All @@ -223,7 +233,7 @@
end

create_table "blazer_audits", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.timestamp "created_at", null: false
t.timestamp "created_at", default: -> { "current_timestamp() ON UPDATE current_timestamp()" }, null: false
t.string "data_source"
t.bigint "query_id"
t.text "statement"
Expand Down Expand Up @@ -451,7 +461,11 @@
t.integer "cost_cents"
t.datetime "created_at", null: false
t.integer "created_by_id"
<<<<<<< HEAD
t.text "description"
=======
t.text "description", size: :medium
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.datetime "end_date", precision: nil
t.boolean "featured", default: false, null: false
t.boolean "inactive", default: true, null: false
Expand All @@ -474,7 +488,11 @@
end

create_table "faqs", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
<<<<<<< HEAD
t.text "answer", size: :medium
=======
t.text "answer", size: :long
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.datetime "created_at", precision: nil, null: false
t.boolean "inactive"
t.integer "position", null: false
Expand All @@ -496,7 +514,11 @@

create_table "form_builders", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
<<<<<<< HEAD
t.text "description", size: :medium
=======
t.text "description", size: :long
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.string "name"
t.integer "owner_type"
t.datetime "updated_at", precision: nil, null: false
Expand Down Expand Up @@ -652,7 +674,11 @@
t.integer "location_id"
t.string "mission_vision_values"
t.string "name"
<<<<<<< HEAD
t.text "notes", size: :medium
=======
t.text "notes", size: :long
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.integer "organization_status_id"
t.boolean "profile_show_description", default: true, null: false
t.boolean "profile_show_email", default: true, null: false
Expand Down Expand Up @@ -686,7 +712,7 @@
t.string "payment_type", default: "stripe", null: false
t.string "status", null: false
t.string "stripe_charge_id"
t.json "stripe_metadata"
t.text "stripe_metadata", size: :long, collation: "utf8mb4_bin"
t.string "stripe_payment_intent_id"
t.datetime "updated_at", null: false
t.index ["event_id"], name: "index_payments_on_event_id"
Expand All @@ -697,6 +723,7 @@
t.index ["payer_type", "payer_id"], name: "index_payments_on_payer_type_and_payer_id"
t.index ["stripe_charge_id"], name: "index_payments_on_stripe_charge_id"
t.index ["stripe_payment_intent_id"], name: "index_payments_on_stripe_payment_intent_id", unique: true
t.check_constraint "json_valid(`stripe_metadata`)", name: "stripe_metadata"
end

create_table "people", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
Expand Down Expand Up @@ -926,7 +953,11 @@

create_table "story_ideas", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.string "author_credit_preference"
<<<<<<< HEAD
t.text "body"
=======
t.text "body", size: :medium
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.datetime "created_at", null: false
t.integer "created_by_id", null: false
t.string "external_workshop_title"
Expand All @@ -945,10 +976,33 @@
t.index ["workshop_id"], name: "index_story_ideas_on_workshop_id"
end

<<<<<<< HEAD
create_table "user_form_form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
t.integer "form_field_id"
t.text "text", size: :medium
=======
create_table "tutorials", charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.text "body"
t.datetime "created_at", null: false
t.boolean "featured", default: false, null: false
t.integer "position", default: 10, null: false
t.boolean "publicly_featured", default: false, null: false
t.boolean "publicly_visible", default: false, null: false
t.boolean "published", default: false, null: false
t.string "title"
t.datetime "updated_at", null: false
t.string "youtube_url"
t.index ["featured"], name: "index_tutorials_on_featured"
t.index ["published"], name: "index_tutorials_on_published"
t.index ["title"], name: "index_tutorials_on_title"
end

create_table "user_form_form_fields", id: :integer, charset: "utf8mb4", collation: "utf8mb4_unicode_ci", force: :cascade do |t|
t.datetime "created_at", precision: nil, null: false
t.integer "form_field_id"
t.text "text", size: :long
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.datetime "updated_at", precision: nil, null: false
t.integer "user_form_id"
t.index ["form_field_id"], name: "index_user_form_form_fields_on_form_field_id"
Expand Down Expand Up @@ -1118,10 +1172,17 @@
t.integer "time_opening"
t.integer "time_opening_circle"
t.integer "time_warm_up"
<<<<<<< HEAD
t.text "timeframe"
t.text "timeframe_spanish"
t.text "tips"
t.text "tips_spanish"
=======
t.text "timeframe", size: :medium
t.text "timeframe_spanish", size: :medium
t.text "tips", size: :medium
t.text "tips_spanish", size: :medium
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.string "title"
t.datetime "updated_at", null: false
t.integer "updated_by_id", null: false
Expand Down Expand Up @@ -1220,14 +1281,20 @@
t.boolean "published", default: false, null: false
t.datetime "updated_at", precision: nil, null: false
t.integer "variation_id"
<<<<<<< HEAD
t.integer "windows_type_id"
=======
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.integer "workshop_id"
t.bigint "workshop_variation_idea_id"
t.string "youtube_url"
t.index ["created_by_id"], name: "index_workshop_variations_on_created_by_id"
t.index ["organization_id"], name: "index_workshop_variations_on_organization_id"
t.index ["published"], name: "index_workshop_variations_on_published"
<<<<<<< HEAD
t.index ["windows_type_id"], name: "index_workshop_variations_on_windows_type_id"
=======
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.index ["workshop_id"], name: "index_workshop_variations_on_workshop_id"
t.index ["workshop_variation_idea_id"], name: "index_workshop_variations_on_workshop_variation_idea_id"
end
Expand Down Expand Up @@ -1302,11 +1369,19 @@
t.integer "time_opening"
t.integer "time_opening_circle"
t.integer "time_warm_up"
<<<<<<< HEAD
t.text "timeframe", size: :medium
t.text "timeframe_spanish", size: :medium
t.text "timestamps", size: :medium
t.text "tips", size: :medium
t.text "tips_spanish", size: :medium
=======
t.text "timeframe", size: :long
t.text "timeframe_spanish", size: :long
t.text "timestamps", size: :long
t.text "tips", size: :long
t.text "tips_spanish", size: :long
>>>>>>> 6515dbbee (Update schema with banner timestamps)
t.string "title"
t.datetime "updated_at", precision: nil, null: false
t.text "visualization", size: :medium
Expand Down
Loading