Summary

Issue: https://github.com/agency-of-learning/PairApp/issues/212

Introduce emoji reactions for each standup post. This allows users to interact with updates more easily and expressively.

Specs

Proposals

A. Associating a reaction to its target

Proposal A1: one action_text_rich_text to many reactions

The most active proposal for standup comments (as of Nov. 16) is not yet written in that design doc, but in essence itโ€™s shown in this POC. In that approach, the StandupMeeting data modelling remains unchanged (still containing the 3 rich text records), and a StandupMeetingComment is associated with a rich text record:

class StandupMeetingComment < ApplicationRecord
  belongs_to :rich_text,
    class_name: 'ActionText::RichText',
    foreign_key: :action_text_rich_text_id

  # This is not in the POC, but I'm guessing we'd need it.
  has_rich_text :text
end

Then 3 queries are added to StandupMeeting, one for each description:

class StandupMeeting < ApplicationRecord
  # ...

  def yesterday_comments
    StandupMeetingComment
      .joins(:rich_text)
      .where(
        action_text_rich_texts: {
          record_id: id,
          record_type: 'StandupMeeting',
          name: 'yesterday_work_description'
        }
      )
  end

  # ... likewise with tomorrow_comments and blockers_comments ...
end

This approach becomes a bit unwieldy if we add in reactions, while ensuring that standup descriptions and comments can both have reactions. (Think of how in GitHub PRs and issues, both the description at the top and subsequent comments can have reactions.)

class StandupMeetingReaction < ApplicationRecord
  belongs_to :rich_text,
    class_name: 'ActionText::RichText',
    foreign_key: :action_text_rich_text_id
  # ...
end

As with comments, weโ€™d need to add a query for each of the 3 descriptions in StandupMeeting:

class StandupMeeting < ApplicationRecord
  # ...

  def yesterday_reactions
    StandupMeetingReaction
      .joins(:rich_text)
      .where(
        action_text_rich_texts: {
          record_id: id,
          record_type: 'StandupMeeting',
          name: 'yesterday_work_description'
        }
      )
  end

  # ... likewise with tomorrow_reactions and blockers_reactions ...
end

Weโ€™d also need to add a query to StandupMeetingComment: