#45 差分表示以外完了

This commit is contained in:
2025-06-18 23:44:33 +09:00
parent c6f7e8a696
commit 0c4ee9744e
4 changed files with 83 additions and 10 deletions
@@ -52,12 +52,17 @@ class WikiPagesController < ApplicationController
def changes
id = params[:id]
log = id.present? ? wiki.page("#{ id }.md").versions : wiki.repo.log('main', nil, max_count: 50)
log = id.present? ? wiki.page("#{ id }.md")&.versions : wiki.repo.log('main', nil, max_count: 50)
return render json: [] unless log
render json: log.map { |commit|
{ sha: commit.id,
author: commit.author.name,
message: commit.message,
timestamp: commit.authored_date } }
wiki_page = WikiPage.find(commit.message.split(' ')[1].to_i)
user = User.find(commit.author.name.to_i)
{ sha: commit.id,
wiki_page: wiki_page && { id: wiki_page.id, title: wiki_page.title },
user: user && { id: user.id, name: user.name },
change_type: commit.message.split(' ')[0].downcase[0...(-1)],
timestamp: commit.authored_date } }
end
private