Skip to content

Commit

Permalink
GET /my-repositories: fix null when search doesn't find any matches
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Oct 12, 2024
1 parent f061466 commit 412ed5c
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions backend/e2e/my-repositories/Get searched.http
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
GET {{server.url}}/api/my-repositories?search=z
2 changes: 2 additions & 0 deletions backend/internal/data/repo_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ func (p PostgresRepoRepo) Get(ctx context.Context, id int64) (repo *Repo, err er
}

func (p PostgresRepoRepo) GetAll(ctx context.Context, searchRepo string, userID int64) (repos []Repo, err error) {
repos = make([]Repo, 0)

query := `
SELECT id, name, user_id
FROM bee_schema.repos
Expand Down
10 changes: 2 additions & 8 deletions backend/internal/server/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,11 @@ func (a *App) getMyRepositories(w http.ResponseWriter, r *http.Request) {

currentPage, err := strconv.Atoi(r.URL.Query().Get("currentPage"))
if err != nil {
msg := "invalid current page"
logger.Warn(msg, slog.Any("error", err))
http.Error(w, msg, http.StatusBadRequest)
return
currentPage = 0
}
pageSize, err := strconv.Atoi(r.URL.Query().Get("pageSize"))
if err != nil {
msg := "invalid page size"
logger.Warn(msg, slog.Any("error", err))
http.Error(w, msg, http.StatusBadRequest)
return
pageSize = 10
}

params := getMyRepositoriesParams{
Expand Down
2 changes: 1 addition & 1 deletion backend/internal/server/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ type pipeline struct {
}

func toRepositories(dbRepos []data.Repo) []repository {
var repos []repository
repos := make([]repository, 0)
for _, repo := range dbRepos {
repos = append(repos, repository{
ID: strconv.FormatInt(repo.ID, 10),
Expand Down
4 changes: 2 additions & 2 deletions backend/server.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ COPY --from=builder /go/bin/dlv /

RUN chmod -R 777 /usr/local/bin/server

# CMD [ "/dlv", "--listen=:40000", "--headless=true", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/server" ]
CMD [ "/dlv", "--listen=:40000", "--headless=true", "--continue", "--api-version=2", "--accept-multiclient", "exec", "/usr/local/bin/server" ]

ENTRYPOINT [ "/usr/local/bin/server" ]
# ENTRYPOINT [ "/usr/local/bin/server" ]
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ services:
init: true
ports:
- "8080:8080"
# - "40000:40000" # debugger port
- "40000:40000" # debugger port
depends_on:
database-postgres:
condition: service_healthy
Expand Down

0 comments on commit 412ed5c

Please sign in to comment.