diff options
author | GrailFinder <wohilas@gmail.com> | 2024-06-02 15:00:41 +0300 |
---|---|---|
committer | GrailFinder <wohilas@gmail.com> | 2024-06-02 15:00:41 +0300 |
commit | 60fc1773241195f4988ed8066e019bbc42267085 (patch) | |
tree | 91dec5a4e298a8b3eb0870649ed8d5031a685001 /internal/handlers/elements.go | |
parent | d0ec9f38b17dadf4c244904e28e064d6ad7c5674 (diff) |
Enha: add db method to list recs
Diffstat (limited to 'internal/handlers/elements.go')
-rw-r--r-- | internal/handlers/elements.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/internal/handlers/elements.go b/internal/handlers/elements.go index 965281a..7fcd9ce 100644 --- a/internal/handlers/elements.go +++ b/internal/handlers/elements.go @@ -1,6 +1,7 @@ package handlers import ( + "apjournal/internal/models" "html/template" "net/http" ) @@ -24,6 +25,20 @@ func (h *Handlers) ServeHideForm(w http.ResponseWriter, r *http.Request) { } func (h *Handlers) ShowRecommended(w http.ResponseWriter, r *http.Request) { + var username string + // TODO: getusername + // TODO: get recommendations for user + plusA, err := h.repo.DBActionRecommend(username, models.ActionTypePlus) + if err != nil { + abortWithError(w, err.Error()) + return + } + minusA, err := h.repo.DBActionRecommend(username, models.ActionTypeMinus) + if err != nil { + abortWithError(w, err.Error()) + return + } + h.log.Debug("got actions", "plus#", len(plusA), "minus#", len(minusA)) tmpl, err := template.ParseGlob("components/*.html") if err != nil { abortWithError(w, err.Error()) |