diff --git a/app/javascript/controllers/event_summary_controller.js b/app/javascript/controllers/event_summary_controller.js deleted file mode 100644 index 4e104a82e..000000000 --- a/app/javascript/controllers/event_summary_controller.js +++ /dev/null @@ -1,40 +0,0 @@ -import { Controller } from "@hotwired/stimulus" - -export default class extends Controller { - static targets = [ "boostEvent" ] - - connect() { - this.#summarizeBoosts() - } - - #summarizeBoosts() { - if (this.#isBoosted) { - const el = document.createElement("span") - el.dataset.turboTemporary = "" - el.textContent = this.#boostSumaries.toSentence() - this.element.appendChild(el) - } - } - - get #isBoosted() { - return this.hasBoostEventTarget - } - - get #boostSumaries() { - return Object.entries(this.#boostsByCreator).map(([_creatorId, boostEvents]) => { - return `${boostEvents[0].dataset.creatorName} +${boostEvents.length}` - }) - } - - get #boostsByCreator() { - return this.boostEventTargets.reduce((acc, target) => { - const creatorId = target.dataset.creatorId - - if (!acc[creatorId]) acc[creatorId] = [] - - acc[creatorId].push(target) - - return acc - }, {}) - } -} diff --git a/app/models/event.rb b/app/models/event.rb index 462f07132..78512132b 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -8,4 +8,6 @@ class Event < ApplicationRecord has_one :account, through: :creator scope :chronologically, -> { order created_at: :asc, id: :desc } + scope :unfurled, -> { where.not action: :boosted } + scope :furled, -> { where action: :boosted } end diff --git a/app/views/event_summaries/_event_summary.html.erb b/app/views/event_summaries/_event_summary.html.erb index c8f8739bd..200cac2f9 100644 --- a/app/views/event_summaries/_event_summary.html.erb +++ b/app/views/event_summaries/_event_summary.html.erb @@ -1,4 +1,7 @@