diff --git a/app/models/bubble.rb b/app/models/bubble.rb index c90ac1075..cda9f2cc0 100644 --- a/app/models/bubble.rb +++ b/app/models/bubble.rb @@ -1,5 +1,5 @@ class Bubble < ApplicationRecord - include Assignable, Boostable, Colored, Commentable, Eventable, + include Assignable, Boostable, Colored, Commentable, Engageable, Eventable, Messages, Notifiable, Pinnable, Poppable, Scorable, Searchable, Staged, Statuses, Taggable, Watchable belongs_to :bucket, touch: true diff --git a/app/models/bubble/engageable.rb b/app/models/bubble/engageable.rb new file mode 100644 index 000000000..a2bfc0812 --- /dev/null +++ b/app/models/bubble/engageable.rb @@ -0,0 +1,30 @@ +module Bubble::Engageable + extend ActiveSupport::Concern + + AUTO_POP_AFTER = 30.days + + included do + has_one :engagement, dependent: :destroy, class_name: "Bubble::Engagement" + + scope :doing, -> { joins(:engagement) } + scope :considering, -> { where.missing(:engagement) } + end + + def doing? + engagement.present? + end + + def considering? + !doing? + end + + def engage + unless doing? + create_engagement! + end + end + + def reconsider + engagement&.destroy + end +end diff --git a/app/models/bubble/engagement.rb b/app/models/bubble/engagement.rb new file mode 100644 index 000000000..1deee74b0 --- /dev/null +++ b/app/models/bubble/engagement.rb @@ -0,0 +1,3 @@ +class Bubble::Engagement < ApplicationRecord + belongs_to :bubble, class_name: "::Bubble" +end diff --git a/db/migrate/20250403094604_create_bubble_engagements.rb b/db/migrate/20250403094604_create_bubble_engagements.rb new file mode 100644 index 000000000..06497be20 --- /dev/null +++ b/db/migrate/20250403094604_create_bubble_engagements.rb @@ -0,0 +1,9 @@ +class CreateBubbleEngagements < ActiveRecord::Migration[8.1] + def change + create_table :bubble_engagements do |t| + t.references :bubble, index: true + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index ef0105d28..ce242daad 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[8.1].define(version: 2025_03_27_191456) do +ActiveRecord::Schema[8.1].define(version: 2025_04_03_094604) do create_table "accesses", force: :cascade do |t| t.integer "bucket_id", null: false t.datetime "created_at", null: false @@ -94,6 +94,13 @@ ActiveRecord::Schema[8.1].define(version: 2025_03_27_191456) do t.index ["bubble_id"], name: "index_assignments_on_bubble_id" end + create_table "bubble_engagements", force: :cascade do |t| + t.integer "bubble_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["bubble_id"], name: "index_bubble_engagements_on_bubble_id" + end + create_table "bubbles", force: :cascade do |t| t.float "activity_score", default: 0.0, null: false t.datetime "activity_score_at" diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 40d083029..c19033c8d 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -21,7 +21,7 @@ columns: default_function: collation: comment: - - &21 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &23 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: bucket_id cast_type: *1 @@ -31,16 +31,6 @@ columns: default_function: collation: comment: - - &30 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: user_id - cast_type: *1 - sql_type_metadata: *2 - 'null': false - default: - default_function: - collation: - comment: - &6 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: created_at @@ -60,7 +50,7 @@ columns: default_function: collation: comment: - - &7 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &9 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: updated_at cast_type: *3 @@ -70,55 +60,9 @@ columns: default_function: collation: comment: - accounts: - - *5 - - &10 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &30 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: name - cast_type: &8 !ruby/object:ActiveModel::Type::String - true: t - false: f - precision: - scale: - limit: - sql_type_metadata: &9 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata - sql_type: varchar - type: :string - limit: - precision: - scale: - 'null': false - default: - default_function: - collation: - comment: - - *6 - - *7 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: join_code - cast_type: *8 - sql_type_metadata: *9 - 'null': true - default: - default_function: - collation: - comment: - action_text_markdowns: - - *5 - - &11 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: record_type - cast_type: *8 - sql_type_metadata: *9 - 'null': false - default: - default_function: - collation: - comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: record_id + name: user_id cast_type: *1 sql_type_metadata: *2 'null': false @@ -126,7 +70,42 @@ columns: default_function: collation: comment: - - *10 + accounts: + - *5 + - *6 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: join_code + cast_type: &7 !ruby/object:ActiveModel::Type::String + true: t + false: f + precision: + scale: + limit: + sql_type_metadata: &8 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata + sql_type: varchar + type: :string + limit: + precision: + scale: + 'null': true + default: + default_function: + collation: + comment: + - &10 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: name + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - *9 + action_text_markdowns: + - *5 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: content @@ -148,21 +127,40 @@ columns: collation: comment: - *6 - - *7 - active_storage_attachments: - - *5 - *10 - - *11 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: record_id - cast_type: &12 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer + cast_type: *1 + sql_type_metadata: *2 + 'null': false + default: + default_function: + collation: + comment: + - &13 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: record_type + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - *9 + active_storage_attachments: + - *5 + - &16 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: blob_id + cast_type: &11 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3Adapter::SQLite3Integer precision: scale: limit: max: 9223372036854775808 min: -9223372036854775808 - sql_type_metadata: &13 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata + sql_type_metadata: &12 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata sql_type: bigint type: :integer limit: @@ -173,22 +171,24 @@ columns: default_function: collation: comment: - - &16 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - *6 + - *10 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: blob_id - cast_type: *12 - sql_type_metadata: *13 + name: record_id + cast_type: *11 + sql_type_metadata: *12 'null': false default: default_function: collation: comment: - - *6 + - *13 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: slug - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: @@ -196,11 +196,11 @@ columns: comment: active_storage_blobs: - *5 - - &17 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: key - cast_type: *8 - sql_type_metadata: *9 + name: byte_size + cast_type: *11 + sql_type_metadata: *12 'null': false default: default_function: @@ -208,10 +208,10 @@ columns: comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: filename - cast_type: *8 - sql_type_metadata: *9 - 'null': false + name: checksum + cast_type: *7 + sql_type_metadata: *8 + 'null': true default: default_function: collation: @@ -219,13 +219,34 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: content_type - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: collation: comment: + - *6 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: filename + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - &17 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: key + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: metadata @@ -239,42 +260,21 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: service_name - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': false default: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: byte_size - cast_type: *12 - sql_type_metadata: *13 - 'null': false - default: - default_function: - collation: - comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: checksum - cast_type: *8 - sql_type_metadata: *9 - 'null': true - default: - default_function: - collation: - comment: - - *6 active_storage_variant_records: - *5 - *16 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: variation_digest - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': false default: default_function: @@ -285,26 +285,16 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: value - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: collation: comment: - *6 - - *7 + - *9 assignees_filters: - - &18 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: filter_id - cast_type: *1 - sql_type_metadata: *2 - 'null': false - default: - default_function: - collation: - comment: - &19 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: assignee_id @@ -315,8 +305,17 @@ columns: default_function: collation: comment: + - &18 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: filter_id + cast_type: *1 + sql_type_metadata: *2 + 'null': false + default: + default_function: + collation: + comment: assigners_filters: - - *18 - &20 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: assigner_id @@ -327,9 +326,11 @@ columns: default_function: collation: comment: + - *18 assignments: - *5 - *19 + - *20 - &25 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: bubble_id @@ -341,32 +342,103 @@ columns: collation: comment: - *6 - - *7 - - *20 + - *9 + bubble_engagements: + - *5 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: bubble_id + cast_type: *1 + sql_type_metadata: *2 + 'null': true + default: + default_function: + collation: + comment: + - *6 + - *9 bubbles: - *5 - - &32 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: title - cast_type: *8 - sql_type_metadata: *9 + name: activity_score + cast_type: &21 !ruby/object:ActiveModel::Type::Float + precision: + scale: + limit: + sql_type_metadata: &22 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata + sql_type: float + type: :float + limit: + precision: + scale: + 'null': false + default: 0.0 + default_function: + collation: + comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: activity_score_at + cast_type: *3 + sql_type_metadata: *4 'null': true default: default_function: collation: comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: activity_score_order + cast_type: *21 + sql_type_metadata: *22 + 'null': false + default: 0.0 + default_function: + collation: + comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: auto_pop_at + cast_type: *3 + sql_type_metadata: *4 + 'null': false + default: + default_function: + collation: + comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: boosts_count + cast_type: *1 + sql_type_metadata: *2 + 'null': false + default: 0 + default_function: + collation: + comment: + - *23 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: color - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: collation: comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: comments_count + cast_type: *1 + sql_type_metadata: *2 + 'null': false + default: 0 + default_function: + collation: + comment: - *6 - - *7 - &24 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: creator_id @@ -396,17 +468,6 @@ columns: default_function: collation: comment: - - *21 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: boosts_count - cast_type: *1 - sql_type_metadata: *2 - 'null': false - default: 0 - default_function: - collation: - comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: stage_id @@ -417,34 +478,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: comments_count - cast_type: *1 - sql_type_metadata: *2 - 'null': false - default: 0 - default_function: - collation: - comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: activity_score - cast_type: &22 !ruby/object:ActiveModel::Type::Float - precision: - scale: - limit: - sql_type_metadata: &23 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata - sql_type: float - type: :float - limit: - precision: - scale: - 'null': false - default: 0.0 - default_function: - collation: - comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: status @@ -455,39 +488,20 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &33 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: auto_pop_at - cast_type: *3 - sql_type_metadata: *4 - 'null': false - default: - default_function: - collation: - comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: activity_score_at - cast_type: *3 - sql_type_metadata: *4 + name: title + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: activity_score_order - cast_type: *22 - sql_type_metadata: *23 - 'null': false - default: 0.0 - default_function: - collation: - comment: + - *9 buckets: - *5 - - &33 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &32 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: account_id cast_type: *1 @@ -497,10 +511,6 @@ columns: default_function: collation: comment: - - *24 - - *10 - - *6 - - *7 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: all_access @@ -519,6 +529,10 @@ columns: default_function: collation: comment: + - *6 + - *24 + - *10 + - *9 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: workflow_id @@ -530,23 +544,45 @@ columns: collation: comment: buckets_filters: + - *23 - *18 - - *21 comments: - *5 - - *24 - *6 - - *7 - creators_filters: - - *18 - *24 + - *9 + creators_filters: + - *24 + - *18 event_summaries: - *5 - *6 - - *7 + - *9 events: - *5 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: action + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - *25 + - *6 - *24 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: due_date + cast_type: *26 + sql_type_metadata: *27 + 'null': true + default: + default_function: + collation: + comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: particulars @@ -565,18 +601,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: action - cast_type: *8 - sql_type_metadata: *9 - 'null': false - default: - default_function: - collation: - comment: - - *6 - - *7 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: summary_id @@ -587,32 +611,11 @@ columns: default_function: collation: comment: - - *25 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: due_date - cast_type: *26 - sql_type_metadata: *27 - 'null': true - default: - default_function: - collation: - comment: + - *9 filters: - *5 - - *24 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: params_digest - cast_type: *8 - sql_type_metadata: *9 - 'null': false - default: - default_function: - collation: - comment: - *6 - - *7 + - *24 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: fields @@ -623,6 +626,17 @@ columns: default_function: collation: comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: params_digest + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - *9 filters_stages: - *18 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -650,16 +664,7 @@ columns: messages: - *5 - *25 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: messageable_type - cast_type: *8 - sql_type_metadata: *9 - 'null': false - default: - default_function: - collation: - comment: + - *6 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: messageable_id @@ -670,11 +675,21 @@ columns: default_function: collation: comment: - - *6 - - *7 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: messageable_type + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - *9 notifications: - *5 - - *30 + - *25 + - *6 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: event_id @@ -685,13 +700,12 @@ columns: default_function: collation: comment: - - *25 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: resource_type - cast_type: *8 - sql_type_metadata: *9 - 'null': false + name: read_at + cast_type: *3 + sql_type_metadata: *4 + 'null': true default: default_function: collation: @@ -706,27 +720,29 @@ columns: default_function: collation: comment: - - *6 - - *7 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: - name: read_at - cast_type: *3 - sql_type_metadata: *4 - 'null': true + name: resource_type + cast_type: *7 + sql_type_metadata: *8 + 'null': false default: default_function: collation: comment: + - *9 + - *30 pins: - *5 - *25 - - *30 - *6 - - *7 + - *9 + - *30 pops: - *5 - *25 + - *6 + - *9 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: user_id @@ -737,8 +753,6 @@ columns: default_function: collation: comment: - - *6 - - *7 reactions: - *5 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -751,16 +765,6 @@ columns: default_function: collation: comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: reacter_id - cast_type: *1 - sql_type_metadata: *2 - 'null': false - default: - default_function: - collation: - comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: content @@ -782,13 +786,23 @@ columns: collation: comment: - *6 - - *7 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: reacter_id + cast_type: *1 + sql_type_metadata: *2 + 'null': false + default: + default_function: + collation: + comment: + - *9 schema_migrations: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: version - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': false default: default_function: @@ -796,41 +810,32 @@ columns: comment: sessions: - *5 - - *30 + - *6 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: ip_address - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: collation: comment: + - *9 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: user_agent - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': true default: default_function: collation: comment: - - *6 - - *7 + - *30 subscriptions: - *5 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: subscribable_type - cast_type: *8 - sql_type_metadata: *9 - 'null': false - default: - default_function: - collation: - comment: + - *6 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: subscribable_id @@ -841,45 +846,33 @@ columns: default_function: collation: comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: subscribable_type + cast_type: *7 + sql_type_metadata: *8 + 'null': false + default: + default_function: + collation: + comment: + - *9 - *30 - - *6 - - *7 taggings: - *5 - *25 - - *31 - *6 - - *7 + - *31 + - *9 tags: - *5 - *32 - *6 - - *7 - *33 + - *9 users: - *5 - - *33 - - *10 - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: email_address - cast_type: *8 - sql_type_metadata: *9 - 'null': true - default: - default_function: - collation: - comment: - - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column - auto_increment: - name: password_digest - cast_type: *8 - sql_type_metadata: *9 - 'null': true - default: - default_function: - collation: - comment: + - *32 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: active @@ -891,21 +884,44 @@ columns: collation: comment: - *6 - - *7 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: email_address + cast_type: *7 + sql_type_metadata: *8 + 'null': true + default: + default_function: + collation: + comment: + - *10 + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: password_digest + cast_type: *7 + sql_type_metadata: *8 + 'null': true + default: + default_function: + collation: + comment: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: role - cast_type: *8 - sql_type_metadata: *9 + cast_type: *7 + sql_type_metadata: *8 'null': false default: member default_function: collation: comment: + - *9 watches: - *5 - - *30 - *25 + - *6 + - *9 + - *30 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: watching @@ -916,10 +932,11 @@ columns: default_function: collation: comment: - - *6 - - *7 workflow_stages: - *5 + - *6 + - *10 + - *9 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: workflow_id @@ -930,15 +947,12 @@ columns: default_function: collation: comment: - - *10 - - *6 - - *7 workflows: - *5 - - *33 - - *10 + - *32 - *6 - - *7 + - *10 + - *9 primary_keys: accesses: id accounts: id @@ -950,6 +964,7 @@ primary_keys: assignees_filters: assigners_filters: assignments: id + bubble_engagements: id bubbles: id buckets: id buckets_filters: @@ -985,6 +1000,7 @@ data_sources: assignees_filters: true assigners_filters: true assignments: true + bubble_engagements: true bubbles: true buckets: true buckets_filters: true @@ -1299,6 +1315,23 @@ indexes: nulls_not_distinct: comment: valid: true + bubble_engagements: + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: bubble_engagements + name: index_bubble_engagements_on_bubble_id + unique: false + columns: + - bubble_id + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true bubbles: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: bubbles @@ -2071,4 +2104,4 @@ indexes: nulls_not_distinct: comment: valid: true -version: 20250327191456 +version: 20250403094604 diff --git a/test/fixtures/bubble/engagements.yml b/test/fixtures/bubble/engagements.yml new file mode 100644 index 000000000..473d868f5 --- /dev/null +++ b/test/fixtures/bubble/engagements.yml @@ -0,0 +1,2 @@ +logo_engagement: + bubble: logo diff --git a/test/models/bubble/engageable_test.rb b/test/models/bubble/engageable_test.rb new file mode 100644 index 000000000..35ec329fd --- /dev/null +++ b/test/models/bubble/engageable_test.rb @@ -0,0 +1,29 @@ +require "test_helper" + +class Bubble::EngageableTest < ActiveSupport::TestCase + test "check the engagement status of a bubble" do + assert bubbles(:logo).doing? + assert_not bubbles(:shipping).doing? + + assert_not bubbles(:logo).considering? + assert bubbles(:shipping).considering? + end + + test "change the engagement" do + assert_changes -> { bubbles(:shipping).reload.doing? }, to: true do + bubbles(:shipping).engage + end + + assert_changes -> { bubbles(:logo).reload.doing? }, to: false do + bubbles(:logo).reconsider + end + end + + test "scopes" do + assert_includes Bubble.doing, bubbles(:logo) + assert_not_includes Bubble.doing, bubbles(:shipping) + + assert_includes Bubble.considering, bubbles(:shipping) + assert_not_includes Bubble.considering, bubbles(:logo) + end +end