Track events on due dates
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="m21.5 3h-2.75-.00000001c-.138071-.00000001-.25-.111929-.25-.25v-1.75c0-.552285-.447715-1-1-1s-1 .447715-1 1v4.75c0 .414214-.335786.75-.75.75h-.00000003c-.414214-.00000002-.75-.335786-.75-.75v-2.25c0-.276142-.223858-.5-.5-.5h-6.25-.00000001c-.137682.00000109-.249449-.11132-.25-.249v-1.751-.00000753c0-.552285-.447715-1-1-1s-1 .447715-1 1v.00001506 4.75c0 .414214-.335786.75-.75.75h-.00000003c-.414214-.00000002-.75-.335786-.75-.75v-2.25001c0-.276142-.223858-.5-.5-.5h-1.5-.00000009c-1.10457.00000005-2 .895431-2 2v17-.0000003c-.00000017 1.10457.89543 2 2 2h19-.00000009c1.10457.00000005 2-.89543 2-2v-17c0-1.10457-.89543-2-2-2zm-.5 19h-18-.00000002c-.276142-.00000001-.5-.223858-.5-.5v-12 .00000008c-.00000004-.276142.223858-.5.5-.5h18-.00000002c.276142-.00000001.5.223858.5.5v12 .00000002c0 .276142-.223858.5-.5.5-.00000001 0-.00000002 0-.00000002 0z"/></svg>
|
||||
|
After Width: | Height: | Size: 929 B |
@@ -65,8 +65,13 @@ module EventsHelper
|
||||
"Popped by #{ event.creator.name }"
|
||||
when "staged"
|
||||
"#{event.creator.name} moved to #{event.stage_name}."
|
||||
when "due_date_added"
|
||||
"#{event.creator.name} set the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}"
|
||||
when "due_date_changed"
|
||||
"#{event.creator.name} changed the date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}"
|
||||
when "due_date_removed"
|
||||
"#{event.creator.name} removed the date"
|
||||
end
|
||||
# FIXME: Should track dates(added/changed) and perhaps "renamed"
|
||||
end
|
||||
|
||||
def event_action_icon(event)
|
||||
@@ -79,6 +84,8 @@ module EventsHelper
|
||||
"bolt"
|
||||
when "unassigned"
|
||||
"remove-med"
|
||||
when "due_date_added", "due_date_changed"
|
||||
"calendar"
|
||||
else
|
||||
"check"
|
||||
end
|
||||
|
||||
@@ -10,6 +10,7 @@ class Bubble < ApplicationRecord
|
||||
has_one_attached :image, dependent: :purge_later
|
||||
|
||||
before_save :set_default_title
|
||||
after_save :track_due_date_change, if: :saved_change_to_due_on?
|
||||
|
||||
scope :reverse_chronologically, -> { order created_at: :desc, id: :desc }
|
||||
scope :chronologically, -> { order created_at: :asc, id: :asc }
|
||||
@@ -32,6 +33,18 @@ class Bubble < ApplicationRecord
|
||||
end
|
||||
|
||||
private
|
||||
def track_due_date_change
|
||||
if due_on.present?
|
||||
if due_on_before_last_save.nil?
|
||||
track_event("due_date_added", particulars: { due_date: due_on })
|
||||
else
|
||||
track_event("due_date_changed", particulars: { due_date: due_on })
|
||||
end
|
||||
elsif due_on_before_last_save.present?
|
||||
track_event("due_date_removed")
|
||||
end
|
||||
end
|
||||
|
||||
def set_default_title
|
||||
self.title = title.presence || "Untitled"
|
||||
end
|
||||
|
||||
@@ -27,6 +27,12 @@ class EventSummary < ApplicationRecord
|
||||
"#{event.creator.name} moved this to '#{event.stage_name}'."
|
||||
when "unstaged"
|
||||
"#{event.creator.name} removed this from '#{event.stage_name}'."
|
||||
when "due_date_added"
|
||||
"#{event.creator.name} set due date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}."
|
||||
when "due_date_changed"
|
||||
"#{event.creator.name} changed due date to #{event.particulars.dig('particulars', 'due_date').to_date.strftime('%B %-d')}."
|
||||
when "due_date_removed"
|
||||
"#{event.creator.name} removed the date."
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
class AddDueDateToEvents < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
add_column :events, :due_date, :date
|
||||
end
|
||||
end
|
||||
Generated
+2
-1
@@ -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_01_21_174109) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2025_02_04_211520) do
|
||||
create_table "accesses", force: :cascade do |t|
|
||||
t.integer "bucket_id", null: false
|
||||
t.integer "user_id", null: false
|
||||
@@ -148,6 +148,7 @@ ActiveRecord::Schema[8.1].define(version: 2025_01_21_174109) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "summary_id", null: false
|
||||
t.integer "bubble_id", null: false
|
||||
t.date "due_date"
|
||||
t.index ["bubble_id"], name: "index_events_on_bubble_id"
|
||||
t.index ["creator_id"], name: "index_events_on_creator_id"
|
||||
t.index ["summary_id", "action"], name: "index_events_on_summary_id_and_action"
|
||||
|
||||
Reference in New Issue
Block a user