FIX fork users list api bug
This commit is contained in:
parent
40d1a288b8
commit
db6e3b0f38
|
@ -94,7 +94,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
|
||||
def fork_users
|
||||
fork_users = @project.fork_users.includes(:user, :project).order("fork_users.created_at desc").distinct
|
||||
fork_users = @project.fork_users.includes(:user, :project, :fork_project).order("fork_users.created_at desc").distinct
|
||||
@forks_count = fork_users.size
|
||||
@fork_users = paginate(fork_users)
|
||||
end
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
class ForkUser < ApplicationRecord
|
||||
belongs_to :project
|
||||
belongs_to :user
|
||||
belongs_to :fork_project, class_name: 'ForkUser', foreign_key: :fork_project_id
|
||||
belongs_to :fork_project, class_name: 'Project', foreign_key: :fork_project_id
|
||||
|
||||
end
|
||||
|
|
|
@ -2,10 +2,9 @@ json.count @forks_count
|
|||
json.users do
|
||||
json.array! @fork_users.each do |f|
|
||||
user = f.user
|
||||
fork_project = Project.select(:id,:name, :identifier).find_by(id: f.fork_project_id)
|
||||
json.id f.fork_project_id
|
||||
json.identifier fork_project.identifier
|
||||
json.name "#{user.try(:show_real_name)}/#{fork_project.try(:name)}"
|
||||
json.id f.fork_project.id
|
||||
json.identifier f.fork_project.identifier
|
||||
json.name "#{user.try(:show_real_name)}/#{f.fork_project.try(:name)}"
|
||||
json.login user.try(:login)
|
||||
json.image_url url_to_avatar(user)
|
||||
json.format_time f.created_at.strftime("%Y-%m-%d")
|
||||
|
|
Loading…
Reference in New Issue