diff --git a/app/models/user/day_timeline.rb b/app/models/user/day_timeline.rb index cf8d08612..6ca015a0f 100644 --- a/app/models/user/day_timeline.rb +++ b/app/models/user/day_timeline.rb @@ -50,18 +50,35 @@ class User::DayTimeline end private + TIMELINEABLE_ACTIONS = %w[ + card_assigned + card_unassigned + card_published + card_closed + card_reopened + card_due_date_added + card_due_date_changed + card_due_date_removed + card_collection_changed + comment_created + ] + def first_day_with_activity_this_week? day.monday? || (earliest_time.present? && earliest_time < day.beginning_of_week(:monday)) end def filtered_events @filtered_events ||= begin - events = Event.where(collection: collections) + events = timelineable_events.where(collection: collections) events = events.where(creator_id: filter.creators.ids) if filter.creators.present? events end end + def timelineable_events + Event.where(action: TIMELINEABLE_ACTIONS) + end + def collections filter.collections.presence || user.collections end diff --git a/app/models/webhook.rb b/app/models/webhook.rb index a766e68f5..d3411e974 100644 --- a/app/models/webhook.rb +++ b/app/models/webhook.rb @@ -15,7 +15,6 @@ class Webhook < ApplicationRecord card_due_date_removed card_published card_reopened - card_title_changed card_unassigned card_unstaged comment_created diff --git a/db/migrate/20251016153034_add_index_to_events_on_collection_id_and_action_and_created_at.rb b/db/migrate/20251016153034_add_index_to_events_on_collection_id_and_action_and_created_at.rb new file mode 100644 index 000000000..1ffe58d7d --- /dev/null +++ b/db/migrate/20251016153034_add_index_to_events_on_collection_id_and_action_and_created_at.rb @@ -0,0 +1,5 @@ +class AddIndexToEventsOnCollectionIdAndActionAndCreatedAt < ActiveRecord::Migration[8.1] + def change + add_index :events, [ :collection_id, :action, :created_at ], name: "index_events_on_collection_id_and_action_and_created_at" + end +end diff --git a/db/schema.rb b/db/schema.rb index b6d4d1ffe..2ae9fd73e 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_10_15_123003) do +ActiveRecord::Schema[8.1].define(version: 2025_10_16_153034) do create_table "accesses", force: :cascade do |t| t.datetime "accessed_at" t.integer "collection_id", null: false @@ -272,6 +272,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_15_123003) do t.json "particulars", default: {} t.datetime "updated_at", null: false t.index ["action"], name: "index_events_on_summary_id_and_action" + t.index ["collection_id", "action", "created_at"], name: "index_events_on_collection_id_and_action_and_created_at" t.index ["collection_id"], name: "index_events_on_collection_id" t.index ["creator_id"], name: "index_events_on_creator_id" t.index ["eventable_type", "eventable_id"], name: "index_events_on_eventable" @@ -403,6 +404,10 @@ ActiveRecord::Schema[8.1].define(version: 2025_10_15_123003) do t.index ["user_id"], name: "index_sessions_on_user_id" end +# Could not dump table "sqlite_stat1" because of following StandardError +# Unknown type '' for column 'idx' + + create_table "steps", force: :cascade do |t| t.integer "card_id", null: false t.boolean "completed", default: false, null: false diff --git a/db/schema_cache.yml b/db/schema_cache.yml index 68e51777c..b4e6b25f2 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -474,12 +474,12 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: due_on - cast_type: &38 !ruby/object:ActiveRecord::Type::Date + cast_type: &40 !ruby/object:ActiveRecord::Type::Date precision: scale: limit: timezone: - sql_type_metadata: &39 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata + sql_type_metadata: &41 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata sql_type: date type: :date limit: @@ -511,7 +511,7 @@ columns: default_function: collation: comment: - - &37 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &39 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: title cast_type: *7 @@ -583,11 +583,11 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: all_access - cast_type: &33 !ruby/object:ActiveModel::Type::Boolean + cast_type: &35 !ruby/object:ActiveModel::Type::Boolean precision: scale: limit: - sql_type_metadata: &34 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata + sql_type_metadata: &36 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata sql_type: boolean type: :boolean limit: @@ -865,7 +865,7 @@ columns: - *9 filters_tags: - *20 - - &36 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &38 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: tag_id cast_type: *3 @@ -982,7 +982,7 @@ columns: - *9 - *18 period_highlights: - - &35 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &37 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: content cast_type: *15 @@ -1107,11 +1107,11 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: rowid - cast_type: !ruby/object:ActiveModel::Type::Value + cast_type: &33 !ruby/object:ActiveModel::Type::Value precision: scale: limit: - sql_type_metadata: !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata + sql_type_metadata: &34 !ruby/object:ActiveRecord::ConnectionAdapters::SqlTypeMetadata sql_type: '' type: limit: @@ -1185,19 +1185,50 @@ columns: - *9 - *32 - *18 + sqlite_stat1: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: idx + cast_type: *33 + sql_type_metadata: *34 + 'null': true + default: + default_function: + collation: + comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: stat + cast_type: *33 + sql_type_metadata: *34 + 'null': true + default: + default_function: + collation: + comment: + - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + auto_increment: + name: tbl + cast_type: *33 + sql_type_metadata: *34 + 'null': true + default: + default_function: + collation: + comment: steps: - *23 - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: completed - cast_type: *33 - sql_type_metadata: *34 + cast_type: *35 + sql_type_metadata: *36 'null': false default: false default_function: collation: comment: - - *35 + - *37 - *5 - *6 - *9 @@ -1205,12 +1236,12 @@ columns: - *23 - *5 - *6 - - *36 + - *38 - *9 tags: - *5 - *6 - - *37 + - *39 - *9 user_settings: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column @@ -1253,8 +1284,8 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: starts_at - cast_type: *38 - sql_type_metadata: *39 + cast_type: *40 + sql_type_metadata: *41 'null': false default: default_function: @@ -1263,11 +1294,11 @@ columns: - *9 - *18 users: - - &41 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &43 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: active - cast_type: *33 - sql_type_metadata: *34 + cast_type: *35 + sql_type_metadata: *36 'null': false default: true default_function: @@ -1316,8 +1347,8 @@ columns: - !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: watching - cast_type: *33 - sql_type_metadata: *34 + cast_type: *35 + sql_type_metadata: *36 'null': false default: true default_function: @@ -1347,7 +1378,7 @@ columns: comment: - *6 - *9 - - &40 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column + - &42 !ruby/object:ActiveRecord::ConnectionAdapters::SQLite3::Column auto_increment: name: webhook_id cast_type: *3 @@ -1401,9 +1432,9 @@ columns: collation: comment: - *9 - - *40 + - *42 webhooks: - - *41 + - *43 - *24 - *5 - *6 @@ -1492,6 +1523,7 @@ primary_keys: search_queries: id search_results: id sessions: id + sqlite_stat1: steps: id taggings: id tags: id @@ -1546,6 +1578,7 @@ data_sources: search_queries: true search_results: true sessions: true + sqlite_stat1: true steps: true taggings: true tags: true @@ -2351,6 +2384,24 @@ indexes: nulls_not_distinct: comment: valid: true + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: events + name: index_events_on_collection_id_and_action_and_created_at + unique: false + columns: + - collection_id + - action + - created_at + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: events name: index_events_on_creator_id @@ -2879,6 +2930,7 @@ indexes: nulls_not_distinct: comment: valid: true + sqlite_stat1: [] steps: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: steps @@ -3197,4 +3249,4 @@ indexes: nulls_not_distinct: comment: valid: true -version: 20251015123003 +version: 20251016153034