Browse Source

Merge pull request 'tidy go.mod, fix spelling mistakes, fix profile search dataset is empty' (#30) from fix-issue-29 into develop

Reviewed-by: pcl <pcl@mail.com>
tags/v1.21.12.1
pcl 5 years ago
parent
commit
98d00cd951
4 changed files with 13 additions and 18 deletions
  1. +10
    -11
      models/dataset.go
  2. +2
    -2
      options/locale/locale_en-US.ini
  3. +1
    -1
      routers/user/profile.go
  4. +0
    -4
      vendor/modules.txt

+ 10
- 11
models/dataset.go View File

@@ -126,25 +126,23 @@ func SearchDataset(opts *SearchDatasetOptions) (DatasetList, int64, error) {

func SearchDatasetCondition(opts *SearchDatasetOptions) builder.Cond {
var cond = builder.NewCond()
cond = cond.And(builder.Neq{"status": DatasetStatusDeleted})
cond = cond.And(builder.Neq{"dataset.status": DatasetStatusDeleted})

if len(opts.Keyword) > 0 {
cond = cond.And(builder.Like{"title", opts.Keyword})
cond = cond.And(builder.Like{"dataset.title", opts.Keyword})
}

if opts.RepoID > 0 {
cond = cond.And(builder.Eq{"repo_id": opts.RepoID})
cond = cond.And(builder.Eq{"dataset.repo_id": opts.RepoID})
}

if opts.IncludePublic {
cond = cond.And(builder.Eq{"status": DatasetStatusPublic})
cond = cond.And(builder.Eq{"dataset.status": DatasetStatusPublic})
if opts.OwnerID > 0 {
cond = cond.Or(builder.Eq{"user_id": opts.OwnerID})
}
} else {
if opts.OwnerID > 0 {
cond = cond.And(builder.Eq{"user_id": opts.OwnerID})
cond = cond.Or(builder.Eq{"repository.owner_id": opts.OwnerID})
}
} else if opts.OwnerID > 0 {
cond = cond.And(builder.Eq{"repository.owner_id": opts.OwnerID})
}

return cond
@@ -161,12 +159,13 @@ func SearchDatasetByCondition(opts *SearchDatasetOptions, cond builder.Cond) (Da

datasets := make(DatasetList, 0, opts.PageSize)

count, err := sess.Where(cond).Count(new(Dataset))
count, err := sess.Join("INNER", "repository", "repository.id = dataset.repo_id").Where(cond).Count(new(Dataset))

if err != nil {
return nil, 0, fmt.Errorf("Count: %v", err)
}

sess.Where(cond).OrderBy(opts.SearchOrderBy.String())
sess.Select("dataset.*").Join("INNER", "repository", "repository.id = dataset.repo_id").Where(cond).OrderBy(opts.SearchOrderBy.String())
if opts.PageSize > 0 {
sess.Limit(opts.PageSize, (opts.Page-1)*opts.PageSize)
}


+ 2
- 2
options/locale/locale_en-US.ini View File

@@ -695,10 +695,10 @@ category.natural_language_processing= natural language processing
category.speech_processing= speech processing
category.computer_vision_natural_language_processing= computer vision and natural language processing
attachment.delete= delete this version of dataset
attachment.delete_desc= Are you sure you will delete this version of dataset, once deelted can not be recovery
attachment.delete_desc= Are you sure you will delete this version of dataset, once deleted can not be recovery
public= public
private= private
delete= deelte
delete= delete

[repo]
owner = Owner


+ 1
- 1
routers/user/profile.go View File

@@ -229,7 +229,7 @@ func Profile(ctx *context.Context) {
ctx.ServerError("SearchDatasets", err)
}
total = int(count)
ctx.Data["datasets"] = datasets
ctx.Data["Datasets"] = datasets
default:
repos, count, err = models.SearchRepository(&models.SearchRepoOptions{
ListOptions: models.ListOptions{


+ 0
- 4
vendor/modules.txt View File

@@ -607,8 +607,6 @@ github.com/spf13/jwalterweatherman
github.com/spf13/pflag
# github.com/spf13/viper v1.4.0
github.com/spf13/viper
# github.com/sqs/goreturns v0.0.0-20181028201513-538ac6014518
## explicit
# github.com/steveyen/gtreap v0.1.0
github.com/steveyen/gtreap
# github.com/stretchr/testify v1.4.0
@@ -640,8 +638,6 @@ github.com/toqueteos/webbrowser
# github.com/tstranex/u2f v1.0.0
## explicit
github.com/tstranex/u2f
# github.com/unknwon/bra v0.0.0-20200517080246-1e3013ecaff8
## explicit
# github.com/unknwon/cae v1.0.0
## explicit
github.com/unknwon/cae


Loading…
Cancel
Save