Skip to content

Conversation

@josefarias
Copy link

@josefarias josefarias commented Nov 16, 2024

These will make it easier to sort bubbles based on these attributes

Was a debugging artifact
* main:
  Truncate headings, too
  Polish filter menu
searchable_by :body, using: :comments_search_index

def captured_as(message)
message.bubble.increment! :comments_count
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considered using counter_cache here: #135

Copy link
Collaborator

@kevinmcconnell kevinmcconnell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the general pattern here looks good -- we'll track the creation & deletion of comments, and increment/decrement a counter accordingly. Then we can cheaply sort bubbles by activity without having to count the associated records 👍

It would be nice if Comment could just track this directly, but I suppose you get into lifecycle problems where they're created before their corresponding Message. Could maybe work around that by using a builder method, but if that ends up feeling awkward then what you're doing here seems best.

def activity_count
boost_count + messages.comments.size
def rescore
update! activity_score: boost_count + messages.comments.size
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're tracking the count of comments, can this be boost_count + comments_count?

Also at this point we could probably just sort by that expression rather than keep an activity_score column, given that all the information is in the other two columns. (That would be assuming we don't need to index this for performance).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes I think at some point I overwrote my changes when deciding to remove #activity_count. Updated!

Re: sorting by expression — we also use this number for determining the size of bubbles. Which, it's just a simple addition, we could do it in-place as well. But since caching the literal score opens up doors to indexing, easy access, and ridiculously simple queries — I'm thinking let's keep the score in the db for now.

Jose Farias added 3 commits November 19, 2024 13:09
* main: (22 commits)
  Fix layout issue that caused comment form to be unselectable
  Stick with stock buttons for now
  Still a little odd that it's a separate form but this conceptually belongs here
  We've got a utility for this
  Fix navbar alignment
  Kind of hate that icon, let's try something else
  Use new bubble shape
  Prevent bubble getting squished
  Fix image fit, try animation
  Don't assume `@filter` is set
  Clicking assignees filters by that assignee
  Restore behavior: clicking tags filters by that tag
  Make these consist from view-to-view
  Improve hover motion for meta bubbles
  No longer used
  Improve assignee bubble display, especially when there are multiple assignees
  name -> key
  ** not required
  Swap one? and many? branches
  Change title based on selected buckets
  ...

private
def created
bubble.comment_created if comment?
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We considered this sort of design as well:

class Message < AR
  after_create :captured
  after_destroy :uncaptured

  private
    def captured
      messageable.captured_as(self)
    end

    def uncaptured
      messageable.uncaptured_as(self)
    end
end

class Comment < AR
  def captured_as(message)
    message.bubble.comment_captured
  end

  def uncaptured_as(message)
    message.bubble.comment_uncaptured
  end
end

But it felt premature in that comments are the only kind of messageable (of which there's only two now) that needs to notify the bubble it's been captured.

We can migrate to that design if needed. Doing the simplest thing for now.

Jose Farias added 3 commits November 19, 2024 13:38
* main:
  Missed one
  Tighten up workflow panel
  Fix test
  Forget about the dividing line for now
  Add some structure to buckets index
  Adjust form
  Restore bucket settings link, adjust styles for filters
  No need for inline svg here anymore
This aligns better with counter_cache conventions, in case we turn boosts into a model later
@josefarias josefarias merged commit aae6124 into main Nov 19, 2024
4 checks passed
@josefarias josefarias deleted the activity-score branch November 19, 2024 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants