@@ -36,6 +36,24 @@ type TagReposSelected struct {
Selected bool
}
type TagsDetail struct {
TagId int64
TagName string
RepoList []RepositoryForTag
}
type RepositoryForTag struct {
TagId int64
TagName string
ID int64
Name string
Description string
NumWatches int
NumStars int
NumForks int
Topics []string
}
func GetTagByID(id int64) (*OfficialTag, error) {
r := &OfficialTag{
ID: id,
@@ -84,7 +102,6 @@ func UpdateTagReposByID(tagID, orgID int64, repoIdList []int64) error {
}
func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) {
t := make([]TagReposBrief, 0)
const SQLCmd = "select t1.id as repo_id,t1.name as repo_name,t2.id as tag_id from repository t1 left join official_tag_repos t2 on (t1.id = t2.repo_id and t2.tag_id = ?) where t1.owner_id = ? and t1.is_private = false"
@@ -105,3 +122,32 @@ func GetTagRepos(tagID, orgID int64) ([]TagReposSelected, error) {
}
return r, nil
}
func GetTagsDetails(orgID int64) ([]TagsDetail, error) {
t := make([]RepositoryForTag, 0)
const SQLCmd = "select t1.tag_id ,t3.name as tag_name,t2.* from official_tag_repos t1 inner join repository t2 on t1.repo_id = t2.id inner join official_tag t3 on t1.tag_id = t3.id where t1.org_id = ?"
if err := x.SQL(SQLCmd, orgID).Find(&t); err != nil {
return nil, err
}
r := make([]TagsDetail, 0)
tempMap := make(map[int64]TagsDetail, 0)
for _, v := range t {
tagId := v.TagId
detail, ok := tempMap[tagId]
if !ok {
detail = TagsDetail{
TagId: v.TagId,
TagName: v.TagName,
RepoList: make([]RepositoryForTag, 0),
}
}
detail.RepoList = append(detail.RepoList, v)
tempMap[tagId] = detail
}
for _, v := range tempMap {
r = append(r, v)
}
return r, nil
}