Skip to content

Commit

Permalink
fix(store): Retrieving repository details for frequency request
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed May 31, 2021
1 parent b4b82f7 commit f089033
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkg/store/ketchup/ketchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ SELECT
rv.version,
k.frequency,
r.id,
r.name,
r.part,
r.kind
k.user_id,
u.email
FROM
Expand All @@ -207,9 +210,9 @@ func (a app) ListOutdatedByFrequency(ctx context.Context, frequency model.Ketchu
scanner := func(rows *sql.Rows) error {
var item model.Ketchup
item.Repository = model.NewRepository(0, 0, "", "")
var rawKetchupFrequency string
var rawKetchupFrequency, rawRepositoryKind string

if err := rows.Scan(&item.Pattern, &item.Version, &rawKetchupFrequency, &item.Repository.ID, &item.User.ID, &item.User.Email); err != nil {
if err := rows.Scan(&item.Pattern, &item.Version, &rawKetchupFrequency, &item.Repository.ID, &item.Repository.Name, &item.Repository.Part, &rawRepositoryKind, &item.User.ID, &item.User.Email); err != nil {
return err
}

Expand All @@ -219,6 +222,12 @@ func (a app) ListOutdatedByFrequency(ctx context.Context, frequency model.Ketchu
}
item.Frequency = ketchupFrequency

repositoryKind, err := model.ParseRepositoryKind(rawRepositoryKind)
if err != nil {
return err
}
item.Repository.Kind = repositoryKind

list = append(list, item)
return nil
}
Expand Down Expand Up @@ -259,8 +268,7 @@ func (a app) GetByRepository(ctx context.Context, id uint64, pattern string, for
}

scanner := func(row *sql.Row) error {
var rawRepositoryKind string
var rawKetchupFrequency string
var rawRepositoryKind, rawKetchupFrequency string

err := row.Scan(&item.Pattern, &item.Version, &rawKetchupFrequency, &item.Repository.ID, &item.User.ID, &item.Repository.Name, &item.Repository.Part, &rawRepositoryKind)
if errors.Is(err, sql.ErrNoRows) {
Expand Down

0 comments on commit f089033

Please sign in to comment.