Skip to content
Closed
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
11 changes: 11 additions & 0 deletions models/repo/org_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,14 @@
func (env *accessibleReposEnv) SetSort(orderBy db.SearchOrderBy) {
env.orderBy = orderBy
}

// Add a new function to filter repositories by a search term
func GetFilteredTeamRepositories(teamID int64, searchTerm string) ([]*Repository, error) {
// Query to fetch repositories with filtering
repos := make([]*Repository, 0, 10)
sess := x.Where("team_id = ?", teamID)

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / test-sqlite

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / test-pgsql

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / test-mysql

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / test-mssql

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / test-unit

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / lint-backend

undefined: x (typecheck)

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / lint-go-gogit

undefined: x (typecheck)

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / lint-go-windows

undefined: x (typecheck)

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x

Check failure on line 186 in models/repo/org_repo.go

View workflow job for this annotation

GitHub Actions / checks-backend

undefined: x
if searchTerm != "" {
sess = sess.And("name LIKE ?", "%"+searchTerm+"%")
}
return repos, sess.Find(&repos)
}
9 changes: 5 additions & 4 deletions routers/web/org/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -416,15 +416,16 @@ func TeamRepositories(ctx *context.Context) {
ctx.Data["PageIsOrgTeams"] = true
ctx.Data["PageIsOrgTeamRepos"] = true

repos, err := repo_model.GetTeamRepositories(ctx, &repo_model.SearchTeamRepoOptions{
TeamID: ctx.Org.Team.ID,
})
searchTerm := ctx.FormTrim("q") // Get the search term from the query parameter
repos, err := repo_model.GetFilteredTeamRepositories(ctx.Org.Team.ID, searchTerm)
if err != nil {
ctx.ServerError("GetTeamRepositories", err)
ctx.ServerError("GetFilteredTeamRepositories", err)
return
}

ctx.Data["Units"] = unit_model.Units
ctx.Data["TeamRepos"] = repos
ctx.Data["SearchTerm"] = searchTerm // Pass the search term back to the template
ctx.HTML(http.StatusOK, tplTeamRepositories)
}

Expand Down
Loading