Browse Source

Merge branch 'fix-1591' of https://git.openi.org.cn/OpenI/aiforge into fix-1591

pull/1693/head
zhoupzh 3 years ago
parent
commit
8b81b2c692
2 changed files with 19 additions and 1 deletions
  1. +9
    -1
      models/attachment.go
  2. +10
    -0
      routers/repo/dataset.go

+ 9
- 1
models/attachment.go View File

@@ -9,6 +9,7 @@ import (
"fmt"
"io"
"path"
"strings"

"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/obs"
@@ -70,6 +71,7 @@ type AttachmentsOptions struct {
NeedIsPrivate bool
IsPrivate bool
NeedRepoInfo bool
Keyword string
}

func (a *Attachment) AfterUpdate() {
@@ -554,8 +556,14 @@ func Attachments(opts *AttachmentsOptions) ([]*AttachmentInfo, int64, error) {

var count int64
var err error
if (opts.Type) >= 0 {
if len(opts.Keyword) == 0 {
count, err = sess.Where(cond).Count(new(Attachment))
} else {
lowerKeyWord := strings.ToLower(opts.Keyword)

cond = cond.And(builder.Or(builder.Like{"LOWER(attachment.name)", lowerKeyWord}))
count, err = sess.Table(&Attachment{}).Where(cond).Count(new(AttachmentInfo))

}

if err != nil {


+ 10
- 0
routers/repo/dataset.go View File

@@ -6,6 +6,7 @@ import (
"regexp"
"sort"
"strconv"
"strings"
"unicode/utf8"

"code.gitea.io/gitea/models"
@@ -286,6 +287,8 @@ func DatasetAction(ctx *context.Context) {
func CurrentRepoDataset(ctx *context.Context) {
page := ctx.QueryInt("page")
cloudbrainType := ctx.QueryInt("type")
keyword := strings.Trim(ctx.Query("search"), " ")

repo := ctx.Repo.Repository
var datasetIDs []int64
dataset, err := models.GetDatasetByRepo(repo)
@@ -299,6 +302,7 @@ func CurrentRepoDataset(ctx *context.Context) {
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
DatasetIDs: datasetIDs,
UploaderID: uploaderID,
Type: cloudbrainType,
@@ -329,6 +333,7 @@ func CurrentRepoDataset(ctx *context.Context) {
func MyDataset(ctx *context.Context) {
page := ctx.QueryInt("page")
cloudbrainType := ctx.QueryInt("type")
keyword := strings.Trim(ctx.Query("search"), " ")

uploaderID := ctx.User.ID
datasets, count, err := models.Attachments(&models.AttachmentsOptions{
@@ -336,6 +341,7 @@ func MyDataset(ctx *context.Context) {
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
UploaderID: uploaderID,
Type: cloudbrainType,
NeedIsPrivate: false,
@@ -365,12 +371,14 @@ func MyDataset(ctx *context.Context) {
func PublicDataset(ctx *context.Context) {
page := ctx.QueryInt("page")
cloudbrainType := ctx.QueryInt("type")
keyword := strings.Trim(ctx.Query("search"), " ")

datasets, count, err := models.Attachments(&models.AttachmentsOptions{
ListOptions: models.ListOptions{
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
NeedIsPrivate: true,
IsPrivate: false,
Type: cloudbrainType,
@@ -400,6 +408,7 @@ func PublicDataset(ctx *context.Context) {
func MyFavoriteDataset(ctx *context.Context) {
page := ctx.QueryInt("page")
cloudbrainType := ctx.QueryInt("type")
keyword := strings.Trim(ctx.Query("search"), " ")

var datasetIDs []int64

@@ -416,6 +425,7 @@ func MyFavoriteDataset(ctx *context.Context) {
Page: page,
PageSize: setting.UI.IssuePagingNum,
},
Keyword: keyword,
DatasetIDs: datasetIDs,
NeedIsPrivate: true,
IsPrivate: false,


Loading…
Cancel
Save