Skip to content

Commit

Permalink
fix(ketchup): Fixing suggestions adding bug
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Jun 27, 2021
1 parent da6b1c2 commit 280d532
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
12 changes: 11 additions & 1 deletion cmd/ketchup/templates/ketchup.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,12 +382,20 @@ <h2 class="header small ellipsis">{{ if eq .Repository.Kind.String "helm" }}{{ .
{{ end }}

{{ with .Suggests }}
<h2 class="separator full">
Suggestions
</h2>

<section class="ketchups">

{{ range . }}
<div class="ketchup center suggest">
<h2 class="header small ellipsis">{{ .Name }}</h2>

<div class="padding">
<img class="icon" src="{{ url "/svg/" }}{{ .Kind.String }}?fill=silver" alt="{{ .Kind.String }} icon">
</div>

<div class="ketchup__version">
<span>
<a href="{{ .URL "stable" }}">{{ .Versions.stable }}</a>
Expand All @@ -398,7 +406,9 @@ <h2 class="header small ellipsis">{{ .Name }}</h2>
<form method="POST" action="/app/ketchups/">
<input type="hidden" name="method" value="POST">
<input type="hidden" name="kind" value="{{ .Kind }}">
<input type="hidden" name="repository" value="{{ .Name }}">
<input type="hidden" name="name" value="{{ .Name }}">
<input type="hidden" name="part" value="{{ .Part }}">
<input type="hidden" name="frequency" value="Daily">
<input type="hidden" name="pattern" value="stable">
<input type="hidden" name="version" value="{{ .Versions.stable }}">

Expand Down
5 changes: 2 additions & 3 deletions pkg/ketchup/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import (
)

const (
suggestThresold = uint64(10)
suggestCount = uint64(5)
suggestThresold = uint64(5)
)

func (a app) PublicTemplateFunc(_ http.ResponseWriter, r *http.Request) (string, int, map[string]interface{}, error) {
Expand Down Expand Up @@ -61,7 +60,7 @@ func (a app) AppTemplateFunc(_ http.ResponseWriter, r *http.Request) (string, in
ketchupIds[index] = ketchup.Repository.ID
}

suggests, err := a.repositoryService.Suggest(r.Context(), ketchupIds, min(suggestThresold-ketchupsCount, suggestCount))
suggests, err := a.repositoryService.Suggest(r.Context(), ketchupIds, min(suggestThresold-ketchupsCount, suggestThresold))
if err != nil {
logger.Warn("unable to get suggest repositories: %s", err)
} else {
Expand Down

0 comments on commit 280d532

Please sign in to comment.