BigW Consortium Gitlab

Commit 8d8c5d9f by Alex Braha Stoll

Simplify WikiPage.group_by_directory by using Enumerable#group_by

parent 77fe503a
......@@ -20,15 +20,8 @@ class WikiPage
# arrays.
def self.group_by_directory(pages)
return {} if pages.blank?
pages = pages.sort_by { |page| [page.directory, page.slug] }
directories = {}
pages.each do |page|
directories[page.directory] ||= []
directories[page.directory] << page
end
directories
pages.sort_by { |page| [page.directory, page.slug] }.
group_by { |page| page.directory }
end
def to_key
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment