Skip to content

Commit

Permalink
fix: Fixing ketchup notifier reminder request
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <[email protected]>
  • Loading branch information
ViBiOh committed Nov 5, 2021
1 parent 355c9fb commit 376f4ca
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions pkg/service/ketchup/ketchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func New(ketchupStore model.KetchupStore, repositoryService model.RepositoryServ
func (a App) List(ctx context.Context, pageSize uint, last string) ([]model.Ketchup, uint64, error) {
list, total, err := a.ketchupStore.List(ctx, pageSize, last)
if err != nil {
return nil, 0, httpModel.WrapInternal(fmt.Errorf("unable to list: %w", err))
return nil, 0, httpModel.WrapInternal(fmt.Errorf("unable to list: %s", err))
}

enrichedList := enrichKetchupsWithSemver(list)
Expand All @@ -48,7 +48,7 @@ func (a App) ListForRepositories(ctx context.Context, repositories []model.Repos

list, err := a.ketchupStore.ListByRepositoriesID(ctx, ids, frequency)
if err != nil {
return nil, httpModel.WrapInternal(fmt.Errorf("unable to list by ids: %w", err))
return nil, httpModel.WrapInternal(fmt.Errorf("unable to list by ids: %s", err))
}

return enrichKetchupsWithSemver(list), nil
Expand All @@ -63,7 +63,7 @@ func (a App) ListOutdatedByFrequency(ctx context.Context, frequency model.Ketchu

list, err := a.ketchupStore.ListOutdatedByFrequency(ctx, frequency, usersIds...)
if err != nil {
return nil, httpModel.WrapInternal(fmt.Errorf("unable to list outdated by frequency: %w", err))
return nil, httpModel.WrapInternal(fmt.Errorf("unable to list outdated by frequency: %s", err))
}

return list, nil
Expand All @@ -86,7 +86,7 @@ func (a App) Create(ctx context.Context, item model.Ketchup) (model.Ketchup, err
}

if _, err := a.ketchupStore.Create(ctx, item); err != nil {
return httpModel.WrapInternal(fmt.Errorf("unable to create: %w", err))
return httpModel.WrapInternal(fmt.Errorf("unable to create: %s", err))
}

output = item
Expand Down Expand Up @@ -115,7 +115,7 @@ func (a App) Update(ctx context.Context, oldPattern string, item model.Ketchup)
err := a.ketchupStore.DoAtomic(ctx, func(ctx context.Context) error {
old, err := a.ketchupStore.GetByRepository(ctx, item.Repository.ID, oldPattern, true)
if err != nil {
return httpModel.WrapInternal(fmt.Errorf("unable to fetch: %w", err))
return httpModel.WrapInternal(fmt.Errorf("unable to fetch: %s", err))
}

if old.Repository.IsZero() {
Expand All @@ -138,14 +138,14 @@ func (a App) Update(ctx context.Context, oldPattern string, item model.Ketchup)
if old.Pattern != item.Pattern {
repo, err := a.repositoryService.GetOrCreate(ctx, old.Repository.Kind, old.Repository.Name, old.Repository.Part, item.Pattern)
if err != nil {
return httpModel.WrapInternal(fmt.Errorf("unable to get repository version: %w", err))
return httpModel.WrapInternal(fmt.Errorf("unable to get repository version: %s", err))
}

current.Repository = repo
}

if err := a.ketchupStore.Update(ctx, current, old.Pattern); err != nil {
return httpModel.WrapInternal(fmt.Errorf("unable to update: %w", err))
return httpModel.WrapInternal(fmt.Errorf("unable to update: %s", err))
}

output = current
Expand Down Expand Up @@ -175,7 +175,7 @@ func (a App) Delete(ctx context.Context, item model.Ketchup) (err error) {
return a.ketchupStore.DoAtomic(ctx, func(ctx context.Context) error {
old, err := a.ketchupStore.GetByRepository(ctx, item.Repository.ID, item.Pattern, true)
if err != nil {
return httpModel.WrapInternal(fmt.Errorf("unable to fetch current: %w", err))
return httpModel.WrapInternal(fmt.Errorf("unable to fetch current: %s", err))
}

if old.Repository.IsZero() {
Expand All @@ -187,7 +187,7 @@ func (a App) Delete(ctx context.Context, item model.Ketchup) (err error) {
}

if err = a.ketchupStore.Delete(ctx, old); err != nil {
return httpModel.WrapInternal(fmt.Errorf("unable to delete: %w", err))
return httpModel.WrapInternal(fmt.Errorf("unable to delete: %s", err))
}

return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/store/ketchup/ketchup.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ func (a App) ListOutdatedByFrequency(ctx context.Context, frequency model.Ketchu
params := []interface{}{strings.ToLower(frequency.String())}

if len(userIds) > 0 {
query += " AND k.user_id IN ($2)"
query += " AND k.user_id = ANY ($2)"
params = append(params, userIds)
}

Expand Down

0 comments on commit 376f4ca

Please sign in to comment.