Skip to content

Commit

Permalink
Memoize commits in Page::AuthorsComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoroth committed Nov 5, 2023
1 parent 1b6dccb commit ba9f1b6
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/components/page/authors_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ def git
end

def commits
@paths.flat_map { |path| git.gblob(path).log.to_a }.sort_by(&:author_date)
end

def page_authors
commits.map(&:author).map { |a| [a.name, a.email] }.tally.keys
rescue => e
puts e
[]
@commits ||= @paths.flat_map { |path| git.gblob(path).log.to_a }.sort_by(&:author_date)
end

def last_commit
commits.last
@last_commit ||= commits.last
end

def last_commit_date
last_commit.try(:author_date)
end

def page_authors
commits.map(&:author).map { |a| [a.name, a.email] }.tally.keys
rescue => e
puts e
[]
end
end

0 comments on commit ba9f1b6

Please sign in to comment.