Update get simpe project api

This commit is contained in:
Jasder 2020-06-29 18:26:22 +08:00
parent e671071420
commit 062a47d889
2 changed files with 14 additions and 5 deletions

View File

@ -100,8 +100,7 @@ class ProjectsController < ApplicationController
end
def simple
project = Project.includes(:owner).select(:id, :name, :identifier, :user_id).find params[:id]
project = Project.includes(:owner, :repository).select(:id, :name, :identifier, :user_id, :project_type).find params[:id]
json_response(project)
end

View File

@ -29,7 +29,17 @@ module ProjectsHelper
end
def json_response(project)
json = {
repo = project.repository
tmp_json = {}
unless project.common?
tmp_json = tmp_json.merge({
mirror_status: repo.mirror_status,
mirror_num: repo.mirror_num,
first_sync: repo.first_sync?
})
end
tmp_json = tmp_json.merge({
identifier: project.identifier,
name: project.name,
id: project.id,
@ -38,7 +48,7 @@ module ProjectsHelper
name: project.owner.real_name,
image_url: url_to_avatar(project.owner)
}
}
render json: json
}).compact
render json: tmp_json
end
end