Module: Sage::QueriesHelper

Defined in:
app/helpers/sage/queries_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_message_date(date) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/sage/queries_helper.rb', line 8

def format_message_date(date)
  case date
  when Date.current
    "Today"
  when Date.current - 1
    "Yesterday"
  else
    if date.year == Date.current.year
      date.strftime("%B %d")
    else
      date.strftime("%B %d, %Y")
    end
  end
end

#messages_grouped_by_day(messages) ⇒ Object



3
4
5
6
# File 'app/helpers/sage/queries_helper.rb', line 3

def messages_grouped_by_day(messages)
  messages.group_by { |message| message.created_at.to_date }
         .sort_by { |date, _| date }
end