Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter inactive repos from search results #282

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ func searchAll(
// use a buffered channel to avoid routine leaks on errs.
ch := make(chan *searchResponse, n)
for _, repo := range repos {
go func(repo string) {
fms, err := idx[repo].Search(query, opts)
ch <- &searchResponse{repo, fms, err}
}(repo)
searcher := idx[repo]

if !opts.IgnoreInactive || !searcher.Repo.Inactive {
go func(repo string) {
fms, err := searcher.Search(query, opts)
ch <- &searchResponse{repo, fms, err}
}(repo)
}
}

res := map[string]*index.SearchResponse{}
Expand Down Expand Up @@ -179,6 +183,7 @@ func Setup(m *http.ServeMux, idx map[string]*searcher.Searcher) {
opt.Offset, opt.Limit = parseRangeValue(r.FormValue("rng"))
opt.FileRegexp = r.FormValue("files")
opt.IgnoreCase = parseAsBool(r.FormValue("i"))
opt.IgnoreInactive = parseAsBool(r.FormValue("ia"))
opt.LinesOfContext = parseAsUintValue(
r.FormValue("ctx"),
0,
Expand Down
1 change: 1 addition & 0 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ type UrlPattern struct {

type Repo struct {
Url string `json:"url"`
Inactive bool `json:"inactive"`
MsBetweenPolls int `json:"ms-between-poll"`
Vcs string `json:"vcs"`
VcsConfigMessage *SecretMessage `json:"vcs-config"`
Expand Down
1 change: 1 addition & 0 deletions index/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type IndexOptions struct {

type SearchOptions struct {
IgnoreCase bool
IgnoreInactive bool
LinesOfContext uint
FileRegexp string
Offset int
Expand Down
Loading