Skip to content

Commit f57901d

Browse files
committed
fix incorrect logic
# Conflicts: # routers/web/repo/projects.go
1 parent 7efebc3 commit f57901d

4 files changed

Lines changed: 5 additions & 17 deletions

File tree

modules/indexer/code/search.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int) (*Res
130130
}
131131

132132
// PerformSearch perform a search on a repository
133-
func PerformSearch(ctx context.Context, opts *SearchOptions) (int, []*Result, []*SearchResultLanguages, error) {
133+
func PerformSearch(ctx context.Context, opts *SearchOptions) (int64, []*Result, []*SearchResultLanguages, error) {
134134
if opts == nil || len(opts.Keyword) == 0 {
135135
return 0, nil, nil, nil
136136
}
@@ -149,5 +149,5 @@ func PerformSearch(ctx context.Context, opts *SearchOptions) (int, []*Result, []
149149
return 0, nil, nil, err
150150
}
151151
}
152-
return int(total), displayResults, resultLanguages, nil
152+
return total, displayResults, resultLanguages, nil
153153
}

routers/web/explore/code.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func Code(ctx *context.Context) {
6666
}
6767

6868
var (
69-
total int
69+
total int64
7070
searchResults []*code_indexer.Result
7171
searchResultLanguages []*code_indexer.SearchResultLanguages
7272
)

routers/web/repo/projects.go

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ func Projects(ctx *context.Context) {
6666
ctx.Data["OpenCount"] = repo.NumOpenProjects
6767
ctx.Data["ClosedCount"] = repo.NumClosedProjects
6868

69-
var total int
70-
if !isShowClosed {
71-
total = repo.NumOpenProjects
72-
} else {
73-
total = repo.NumClosedProjects
74-
}
75-
7669
projects, count, err := db.FindAndCount[project_model.Project](ctx, project_model.SearchOptions{
7770
ListOptions: db.ListOptions{
7871
PageSize: setting.UI.IssuePagingNum,
@@ -111,12 +104,7 @@ func Projects(ctx *context.Context) {
111104
ctx.Data["State"] = "open"
112105
}
113106

114-
numPages := 0
115-
if count > 0 {
116-
numPages = (int(count) - 1/setting.UI.IssuePagingNum)
117-
}
118-
119-
pager := context.NewPagination(total, setting.UI.IssuePagingNum, page, numPages)
107+
pager := context.NewPagination(count, setting.UI.IssuePagingNum, page, 5)
120108
pager.AddParamFromRequest(ctx.Req)
121109
ctx.Data["Page"] = pager
122110

services/repository/adopt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func DeleteUnadoptedRepository(ctx context.Context, doer, u *user_model.User, re
240240

241241
type unadoptedRepositories struct {
242242
repositories []string
243-
index int
243+
index int // FIXME: it should be int64 and the name should be "counter"
244244
start int
245245
end int
246246
}

0 commit comments

Comments
 (0)