Skip to content

Commit 1f412a9

Browse files
committed
issue/pull search allow fuzzy search
1 parent 5014cf1 commit 1f412a9

File tree

2 files changed

+26
-18
lines changed

2 files changed

+26
-18
lines changed

routers/web/user/home.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
447447
User: ctx.Doer,
448448
}
449449

450+
isFuzzy := ctx.FormBool("fuzzy")
451+
450452
// Search all repositories which
451453
//
452454
// As user:
@@ -549,7 +551,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
549551
// USING FINAL STATE OF opts FOR A QUERY.
550552
var issues issues_model.IssueList
551553
{
552-
issueIDs, _, err := issue_indexer.SearchIssues(ctx, issue_indexer.ToSearchOptions(keyword, opts))
554+
issueSearchOptions := issue_indexer.ToSearchOptions(keyword, opts)
555+
issueSearchOptions.IsFuzzyKeyword = isFuzzy
556+
issueIDs, _, err := issue_indexer.SearchIssues(ctx, issueSearchOptions)
553557
if err != nil {
554558
ctx.ServerError("issueIDsFromSearch", err)
555559
return
@@ -570,7 +574,9 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
570574
// -------------------------------
571575
// Fill stats to post to ctx.Data.
572576
// -------------------------------
573-
issueStats, err := getUserIssueStats(ctx, ctxUser, filterMode, issue_indexer.ToSearchOptions(keyword, opts))
577+
issueSearchOptions := issue_indexer.ToSearchOptions(keyword, opts)
578+
issueSearchOptions.IsFuzzyKeyword = isFuzzy
579+
issueStats, err := getUserIssueStats(ctx, ctxUser, filterMode, issueSearchOptions)
574580
if err != nil {
575581
ctx.ServerError("getUserIssueStats", err)
576582
return
@@ -624,6 +630,7 @@ func buildIssueOverview(ctx *context.Context, unitType unit.Type) {
624630
ctx.Data["SortType"] = sortType
625631
ctx.Data["IsShowClosed"] = isShowClosed
626632
ctx.Data["SelectLabels"] = selectedLabels
633+
ctx.Data["IsFuzzy"] = isFuzzy
627634

628635
if isShowClosed {
629636
ctx.Data["State"] = "closed"

templates/user/dashboard/issues.tmpl

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@
55
<div class="flex-container">
66
<div class="flex-container-nav">
77
<div class="ui secondary vertical filter menu tw-bg-transparent">
8-
<a class="{{if eq .ViewType "your_repositories"}}active{{end}} item" href="{{.Link}}?type=your_repositories&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
8+
<a class="{{if eq .ViewType "your_repositories"}}active{{end}} item" href="{{.Link}}?type=your_repositories&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
99
{{ctx.Locale.Tr "home.issues.in_your_repos"}}
1010
<strong>{{CountFmt .IssueStats.YourRepositoriesCount}}</strong>
1111
</a>
12-
<a class="{{if eq .ViewType "assigned"}}active{{end}} item" href="{{.Link}}?type=assigned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
12+
<a class="{{if eq .ViewType "assigned"}}active{{end}} item" href="{{.Link}}?type=assigned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
1313
{{ctx.Locale.Tr "repo.issues.filter_type.assigned_to_you"}}
1414
<strong>{{CountFmt .IssueStats.AssignCount}}</strong>
1515
</a>
16-
<a class="{{if eq .ViewType "created_by"}}active{{end}} item" href="{{.Link}}?type=created_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
16+
<a class="{{if eq .ViewType "created_by"}}active{{end}} item" href="{{.Link}}?type=created_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
1717
{{ctx.Locale.Tr "repo.issues.filter_type.created_by_you"}}
1818
<strong>{{CountFmt .IssueStats.CreateCount}}</strong>
1919
</a>
2020
{{if .PageIsPulls}}
21-
<a class="{{if eq .ViewType "review_requested"}}active{{end}} item" href="{{.Link}}?type=review_requested&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
21+
<a class="{{if eq .ViewType "review_requested"}}active{{end}} item" href="{{.Link}}?type=review_requested&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
2222
{{ctx.Locale.Tr "repo.issues.filter_type.review_requested"}}
2323
<strong>{{CountFmt .IssueStats.ReviewRequestedCount}}</strong>
2424
</a>
25-
<a class="{{if eq .ViewType "reviewed_by"}}active{{end}} item" href="{{.Link}}?type=reviewed_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
25+
<a class="{{if eq .ViewType "reviewed_by"}}active{{end}} item" href="{{.Link}}?type=reviewed_by&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
2626
{{ctx.Locale.Tr "repo.issues.filter_type.reviewed_by_you"}}
2727
<strong>{{CountFmt .IssueStats.ReviewedCount}}</strong>
2828
</a>
2929
{{end}}
30-
<a class="{{if eq .ViewType "mentioned"}}active{{end}} item" href="{{.Link}}?type=mentioned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}">
30+
<a class="{{if eq .ViewType "mentioned"}}active{{end}} item" href="{{.Link}}?type=mentioned&sort={{$.SortType}}&state={{.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
3131
{{ctx.Locale.Tr "repo.issues.filter_type.mentioning_you"}}
3232
<strong>{{CountFmt .IssueStats.MentionCount}}</strong>
3333
</a>
@@ -36,11 +36,11 @@
3636
<div class="flex-container-main content">
3737
<div class="list-header">
3838
<div class="small-menu-items ui compact tiny menu list-header-toggle">
39-
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=open&q={{$.Keyword}}">
39+
<a class="item{{if not .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=open&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
4040
{{svg "octicon-issue-opened" 16 "gt-mr-3"}}
4141
{{ctx.Locale.PrettyNumber .IssueStats.OpenCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.open_title"}}
4242
</a>
43-
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=closed&q={{$.Keyword}}">
43+
<a class="item{{if .IsShowClosed}} active{{end}}" href="{{.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state=closed&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">
4444
{{svg "octicon-issue-closed" 16 "gt-mr-3"}}
4545
{{ctx.Locale.PrettyNumber .IssueStats.ClosedCount}}&nbsp;{{ctx.Locale.Tr "repo.issues.closed_title"}}
4646
</a>
@@ -51,6 +51,7 @@
5151
<input type="hidden" name="sort" value="{{$.SortType}}">
5252
<input type="hidden" name="state" value="{{$.State}}">
5353
{{template "shared/searchinput" dict "Value" $.Keyword}}
54+
{{template "shared/searchfuzzy" dict "Disabled" false "IsFuzzy" .IsFuzzy "Topic" "repo"}}
5455
<button id="issue-list-quick-goto" class="ui small icon button gt-hidden" data-tooltip-content="{{ctx.Locale.Tr "explore.go_to"}}">{{svg "octicon-hash"}}</button>
5556
<button class="ui small icon button" aria-label="{{ctx.Locale.Tr "explore.search"}}">{{svg "octicon-search"}}</button>
5657
</div>
@@ -62,14 +63,14 @@
6263
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
6364
</span>
6465
<div class="menu">
65-
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=recentupdate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
66-
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastupdate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
67-
<a class="{{if or (eq .SortType "latest") (not .SortType)}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=latest&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
68-
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=oldest&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
69-
<a class="{{if eq .SortType "mostcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=mostcomment&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a>
70-
<a class="{{if eq .SortType "leastcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastcomment&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a>
71-
<a class="{{if eq .SortType "nearduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=nearduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a>
72-
<a class="{{if eq .SortType "farduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=farduedate&state={{$.State}}&q={{$.Keyword}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a>
66+
<a class="{{if eq .SortType "recentupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=recentupdate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.recentupdate"}}</a>
67+
<a class="{{if eq .SortType "leastupdate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastupdate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastupdate"}}</a>
68+
<a class="{{if or (eq .SortType "latest") (not .SortType)}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=latest&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.latest"}}</a>
69+
<a class="{{if eq .SortType "oldest"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=oldest&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.oldest"}}</a>
70+
<a class="{{if eq .SortType "mostcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=mostcomment&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.mostcomment"}}</a>
71+
<a class="{{if eq .SortType "leastcomment"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=leastcomment&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.leastcomment"}}</a>
72+
<a class="{{if eq .SortType "nearduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=nearduedate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.nearduedate"}}</a>
73+
<a class="{{if eq .SortType "farduedate"}}active {{end}}item" href="{{$.Link}}?type={{$.ViewType}}&sort=farduedate&state={{$.State}}&q={{$.Keyword}}&fuzzy={{.IsFuzzy}}">{{ctx.Locale.Tr "repo.issues.filter_sort.farduedate"}}</a>
7374
</div>
7475
</div>
7576
</div>

0 commit comments

Comments
 (0)