diff --git a/app/controllers/admin/prompt_sandboxes_controller.rb b/app/controllers/admin/prompt_sandboxes_controller.rb index 522fe5955..b4d6578ea 100644 --- a/app/controllers/admin/prompt_sandboxes_controller.rb +++ b/app/controllers/admin/prompt_sandboxes_controller.rb @@ -22,7 +22,7 @@ class Admin::PromptSandboxesController < AdminController private def build_weekly_highlights - period = PeriodHighlights::Period.new(Current.user.collections, starts_at: @day_timeline.day.utc.beginning_of_week(:sunday), duration: 1.week) + period = PeriodHighlights::Period.new(Current.user.collections, starts_at: @day_timeline.day.beginning_of_week(:sunday), duration: 1.week) summarizer = Event::Summarizer.new(period.events, prompt: @prompt, llm_model: @llm_model) content = summarizer.summarized_content PeriodHighlights.new(content: content, cost_in_microcents: summarizer.cost.in_microcents) diff --git a/app/models/period_highlights/period.rb b/app/models/period_highlights/period.rb index 21e58686c..a0fe2b2b2 100644 --- a/app/models/period_highlights/period.rb +++ b/app/models/period_highlights/period.rb @@ -18,7 +18,7 @@ class PeriodHighlights::Period end def key - @keu ||= Digest::SHA256.hexdigest(events.ids.sort.join("-")) + @key ||= Digest::SHA256.hexdigest(events.ids.sort.join("-")) end private @@ -27,6 +27,6 @@ class PeriodHighlights::Period end def normalize_anchor_date(date) - date.utc.beginning_of_day + date.beginning_of_day end end diff --git a/app/models/user/day_timeline.rb b/app/models/user/day_timeline.rb index 0beb3901d..754cdefc5 100644 --- a/app/models/user/day_timeline.rb +++ b/app/models/user/day_timeline.rb @@ -34,7 +34,15 @@ class User::DayTimeline end def weekly_highlights - @weekly_highlights ||= user.weekly_highlights_for(day - 1.week) + @weekly_highlights ||= user.weekly_highlights_for(week_starts_at - 1.week) + end + + def week_starts_at + day.beginning_of_week(:sunday) + end + + def week_ends_at + week_starts_at + 1.week end private diff --git a/app/models/user/role.rb b/app/models/user/role.rb index 4bc09b518..4a90410b5 100644 --- a/app/models/user/role.rb +++ b/app/models/user/role.rb @@ -3,7 +3,6 @@ module User::Role included do enum :role, %i[ admin member system ].index_by(&:itself), scopes: false - scope :regular, -> { where(role: %i[ admin member ]) } scope :member, -> { where(role: :member) } scope :active, -> { where(active: true, role: %i[ admin member ]) } diff --git a/app/views/events/_day.html.erb b/app/views/events/_day.html.erb index 29507f4c8..9a3b81315 100644 --- a/app/views/events/_day.html.erb +++ b/app/views/events/_day.html.erb @@ -1,6 +1,7 @@
<% if day_timeline.has_activity? %> +
highlights: <%= day_timeline.has_weekly_highlights? %>
<%= render "events/day_timeline_column", event_type: "added", day_timeline: day_timeline %> <%= render "events/day_timeline_column", event_type: "updated", day_timeline: day_timeline %> diff --git a/app/views/events/_weekly_highlights.html.erb b/app/views/events/_weekly_highlights.html.erb index 49601115b..1e1324e08 100644 --- a/app/views/events/_weekly_highlights.html.erb +++ b/app/views/events/_weekly_highlights.html.erb @@ -3,9 +3,9 @@ Weekly Highlights for - <%= local_datetime_tag day_timeline.weekly_highlights.starts_at, style: :shortdate %> + <%= local_datetime_tag day_timeline.week_starts_at, style: :shortdate %> – - <%= local_datetime_tag day_timeline.weekly_highlights.ends_at, style: :shortdate %> + <%= local_datetime_tag day_timeline.week_ends_at - 1.day, style: :shortdate %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index d716fb07d..4176e8c3f 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -9,7 +9,7 @@ <%= render "layouts/shared/flash" %> - <%= render "layouts/shared/time_zone" %> + <%= render "layouts/shared/time_zone" if Current.user %>
<%= yield %> diff --git a/db/schema.rb b/db/schema.rb index a5990ff46..83da335e8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -419,6 +419,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_09_05_101432) do t.datetime "created_at", null: false t.string "title" t.datetime "updated_at", null: false + t.index ["title"], name: "index_tags_on_account_id_and_title", unique: true end create_table "user_settings", force: :cascade do |t| diff --git a/db/schema_cache.yml b/db/schema_cache.yml index f0d150190..747b9a87d 100644 --- a/db/schema_cache.yml +++ b/db/schema_cache.yml @@ -2858,7 +2858,23 @@ indexes: nulls_not_distinct: comment: valid: true - tags: [] + tags: + - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition + table: tags + name: index_tags_on_account_id_and_title + unique: true + columns: + - title + lengths: {} + orders: {} + opclasses: {} + where: + type: + using: + include: + nulls_not_distinct: + comment: + valid: true user_settings: - !ruby/object:ActiveRecord::ConnectionAdapters::IndexDefinition table: user_settings