Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions app/models/list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ def initialize(name, id)
List.new('ruby-talk', 4),
]

def self.find_by_name(name)
LISTS.find { |list| list.name == name }
end
class << self
def find_by_name(name)
List::LISTS.find { |list| list.name == name }
end

def find_by_id(id)
List::LISTS.find { |list| list.id == id }
end

def self.find_by_id(id)
LISTS.find { |list| list.id == id }
alias find find_by_id
end
end
4 changes: 2 additions & 2 deletions app/models/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ def from_string(str)
end

def list
@list ||= List.find_by_id(list_id)
@list ||= List.find(list_id)
end

def count_recursively(count = 0)
count + 1 + (children&.sum(&:count_recursively) || 0)
end

def reload_from_s3(s3_client = Aws::S3::Client.new(region: BLADE_BUCKET_REGION))
m = Message.from_s3(List.find_by_id(self.list_id).name, self.list_seq, s3_client)
m = Message.from_s3(List.find(self.list_id).name, self.list_seq, s3_client)

self.body = m.body
self.subject = m.subject
Expand Down
2 changes: 1 addition & 1 deletion app/views/messages/search.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<% @messages.each do |message| %>
<div class="search-result">
<% list_name = List.find_by_id(message.list_id).name %>
<% list_name = List.find(message.list_id).name %>
<h2 class="subject">
<span class="prefix"><%= list_name %>:<%= message.list_seq %></span>
<%= link_to without_list_prefix(message.subject), "/#{list_name}/#{message.list_seq}" %>
Expand Down