Add project star and fork count, group avatar URL and user/group web URL attributes to API
This commit is contained in:
parent
43d1188031
commit
a784b996b3
|
@ -16,6 +16,7 @@ v 7.14.0 (unreleased)
|
||||||
- Expire Rails cache entries after two weeks to prevent endless Redis growth
|
- Expire Rails cache entries after two weeks to prevent endless Redis growth
|
||||||
- Add support for destroying project milestones (Stan Hu)
|
- Add support for destroying project milestones (Stan Hu)
|
||||||
- Add fetch command to the MR page
|
- Add fetch command to the MR page
|
||||||
|
- Add project star and fork count, group avatar URL and user/group web URL attributes to API
|
||||||
|
|
||||||
v 7.13.1
|
v 7.13.1
|
||||||
- Fix: Label modifications are not reflected in existing notes and in the issue list
|
- Fix: Label modifications are not reflected in existing notes and in the issue list
|
||||||
|
|
|
@ -17,6 +17,7 @@ require 'carrierwave/orm/activerecord'
|
||||||
require 'file_size_validator'
|
require 'file_size_validator'
|
||||||
|
|
||||||
class Group < Namespace
|
class Group < Namespace
|
||||||
|
include Gitlab::ConfigHelper
|
||||||
include Referable
|
include Referable
|
||||||
|
|
||||||
has_many :group_members, dependent: :destroy, as: :source, class_name: 'GroupMember'
|
has_many :group_members, dependent: :destroy, as: :source, class_name: 'GroupMember'
|
||||||
|
@ -56,6 +57,16 @@ class Group < Namespace
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def avatar_url(size = nil)
|
||||||
|
if avatar.present?
|
||||||
|
[gitlab_config.url, avatar.url].join
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def web_url
|
||||||
|
[gitlab_config.url, "groups", self.path].join('/')
|
||||||
|
end
|
||||||
|
|
||||||
def owners
|
def owners
|
||||||
@owners ||= group_members.owners.map(&:user)
|
@owners ||= group_members.owners.map(&:user)
|
||||||
end
|
end
|
||||||
|
|
|
@ -637,6 +637,10 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def web_url
|
||||||
|
[gitlab_config.url, "u", self.username].join('/')
|
||||||
|
end
|
||||||
|
|
||||||
def all_emails
|
def all_emails
|
||||||
[self.email, *self.emails.map(&:email)]
|
[self.email, *self.emails.map(&:email)]
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,7 @@ module API
|
||||||
end
|
end
|
||||||
|
|
||||||
class UserBasic < UserSafe
|
class UserBasic < UserSafe
|
||||||
expose :id, :state, :avatar_url
|
expose :id, :state, :avatar_url, :web_url
|
||||||
end
|
end
|
||||||
|
|
||||||
class User < UserBasic
|
class User < UserBasic
|
||||||
|
@ -59,6 +59,7 @@ module API
|
||||||
expose :namespace
|
expose :namespace
|
||||||
expose :forked_from_project, using: Entities::ForkedFromProject, if: lambda{ | project, options | project.forked? }
|
expose :forked_from_project, using: Entities::ForkedFromProject, if: lambda{ | project, options | project.forked? }
|
||||||
expose :avatar_url
|
expose :avatar_url
|
||||||
|
expose :star_count, :forks_count
|
||||||
end
|
end
|
||||||
|
|
||||||
class ProjectMember < UserBasic
|
class ProjectMember < UserBasic
|
||||||
|
@ -69,6 +70,7 @@ module API
|
||||||
|
|
||||||
class Group < Grape::Entity
|
class Group < Grape::Entity
|
||||||
expose :id, :name, :path, :description
|
expose :id, :name, :path, :description
|
||||||
|
expose :avatar_url, :web_url
|
||||||
end
|
end
|
||||||
|
|
||||||
class GroupDetail < Group
|
class GroupDetail < Group
|
||||||
|
|
Loading…
Reference in New Issue