fix: change sql to improve the performance of catalog api (#14820)

Signed-off-by: chlins <chlins.zhang@gmail.com>
This commit is contained in:
ChenYu Zhang 2021-05-20 15:52:53 +08:00 committed by GitHub
parent 8600b06975
commit a50f782beb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -16,7 +16,6 @@ package dao
import (
"context"
"fmt"
"time"
o "github.com/astaxie/beego/orm"
@ -160,7 +159,7 @@ func (d *dao) NonEmptyRepos(ctx context.Context) ([]*model.RepoRecord, error) {
return nil, err
}
sql := fmt.Sprintf(`select distinct r.* from repository as r LEFT JOIN tag as t on r.repository_id = t.repository_id where t.repository_id is not null;`)
sql := `select * from repository where repository_id in (select distinct repository_id from tag)`
_, err = ormer.Raw(sql).QueryRows(&repos)
if err != nil {
return repos, err