From 2f1912c1d221aac54e56655965e2009f889f5f9b Mon Sep 17 00:00:00 2001 From: ychao_1983 Date: Tue, 31 Jan 2023 12:53:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/tech_converge_info.go | 42 ++++++++++++++++++++++-------------------- services/tech/tech.go | 17 +++++++++-------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/models/tech_converge_info.go b/models/tech_converge_info.go index a13c216c8..b8b80b3ac 100644 --- a/models/tech_converge_info.go +++ b/models/tech_converge_info.go @@ -314,15 +314,16 @@ type SearchRepoOpt struct { } type RepoWithInstitution struct { - ID int64 `json:"id"` - OwnerID int64 `json:"owner_id"` - OwnerName string `json:"owner_name"` - Name string `json:"name"` - Alias string `json:"alias"` - Topics []string `json:"topics"` - Description string `json:"description"` - Institution string `json:"institution"` - UpdatedUnix timeutil.TimeStamp `json:"updated_unix"` + ID int64 `json:"id"` + OwnerID int64 `json:"owner_id"` + OwnerName string `json:"owner_name"` + Name string `json:"name"` + Alias string `json:"alias"` + Topics []string `json:"topics"` + Description string `json:"description"` + Institution string `json:"institution"` + RelAvatarLink string `json:"rel_avatar_link"` + UpdatedUnix timeutil.TimeStamp `json:"updated_unix"` } type TechRepoInfo struct { @@ -416,7 +417,7 @@ func buildTechFilterCond(opt *SearchTechOpt) string { sql += getWherePrefix(sql) + " apply_year =" + strconv.Itoa(opt.ApplyYear) } if opt.Institution != "" { - sql += getWherePrefix(sql) + " (all_institution like '%" + opt.Institution + ",%'" + " or all_institution like '%," + opt.Institution + "%'" + sql += getWherePrefix(sql) + " (all_institution like '%" + opt.Institution + ",%'" + " or all_institution like '%," + opt.Institution + "%'" + " or all_institution = '" + opt.Institution + "')" } if opt.ExecuteYear != 0 { @@ -445,7 +446,7 @@ func loadRepoInfoForTech(list []*TechRepoInfo) { techRepo.Repos = []*RepoWithInstitution{} if techRepo.RepoCount > 0 { var repoIds []int64 - x.Table("repo_converge_info").Cols("repo_id").Where("base_info_id=?", techRepo.ID).Desc("updated_unix").Find(&repoIds) + x.Table("repo_converge_info").Cols("repo_id").Where("base_info_id=?", techRepo.ID).Limit(2).Desc("updated_unix").Find(&repoIds) resultMap, err := GetRepositoriesMapByIDs(repoIds) @@ -455,15 +456,16 @@ func loadRepoInfoForTech(list []*TechRepoInfo) { repo, ok := resultMap[repoId] if ok { techRepo.Repos = append(techRepo.Repos, &RepoWithInstitution{ - ID: repo.ID, - Institution: techRepo.Institution, - OwnerID: repo.OwnerID, - OwnerName: repo.OwnerName, - Name: repo.Name, - Alias: repo.Alias, - Topics: repo.Topics, - Description: repo.Description, - UpdatedUnix: repo.UpdatedUnix, + ID: repo.ID, + Institution: techRepo.Institution, + OwnerID: repo.OwnerID, + OwnerName: repo.OwnerName, + Name: repo.Name, + Alias: repo.Alias, + Topics: repo.Topics, + Description: repo.Description, + RelAvatarLink: repo.RelAvatarLink(), + UpdatedUnix: repo.UpdatedUnix, }) } diff --git a/services/tech/tech.go b/services/tech/tech.go index 28b52c84c..b839a0eed 100644 --- a/services/tech/tech.go +++ b/services/tech/tech.go @@ -39,14 +39,15 @@ func SearchRepoInfoWithInstitution(opt *models.SearchRepoOpt) ([]*models.RepoWit for _, repo := range result.Repos { repoResult = append(repoResult, &models.RepoWithInstitution{ - ID: repo.ID, - OwnerID: repo.OwnerID, - OwnerName: repo.OwnerName, - Name: repo.Name, - Topics: repo.Topics, - Description: repo.Description, - Institution: institutionMap[repo.ID], - UpdatedUnix: repo.UpdatedUnix, + ID: repo.ID, + OwnerID: repo.OwnerID, + OwnerName: repo.OwnerName, + Name: repo.Name, + Topics: repo.Topics, + Description: repo.Description, + Institution: institutionMap[repo.ID], + RelAvatarLink: repo.RelAvatarLink, + UpdatedUnix: repo.UpdatedUnix, }) }