category_refresh.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright 2018 Frédéric Guillot. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. package ui // import "miniflux.app/ui"
  5. import (
  6. "net/http"
  7. "miniflux.app/http/request"
  8. "miniflux.app/http/response/html"
  9. "miniflux.app/http/route"
  10. )
  11. func (h *handler) refreshCategoryEntriesPage(w http.ResponseWriter, r *http.Request) {
  12. categoryID := h.refreshCategory(w, r)
  13. html.Redirect(w, r, route.Path(h.router, "categoryEntries", "categoryID", categoryID))
  14. }
  15. func (h *handler) refreshCategoryFeedsPage(w http.ResponseWriter, r *http.Request) {
  16. categoryID := h.refreshCategory(w, r)
  17. html.Redirect(w, r, route.Path(h.router, "categoryFeeds", "categoryID", categoryID))
  18. }
  19. func (h *handler) refreshCategory(w http.ResponseWriter, r *http.Request) int64 {
  20. userID := request.UserID(r)
  21. categoryID := request.RouteInt64Param(r, "categoryID")
  22. jobs, err := h.store.NewCategoryBatch(userID, categoryID, h.store.CountFeeds(userID))
  23. if err != nil {
  24. html.ServerError(w, r, err)
  25. return 0
  26. }
  27. go func() {
  28. h.pool.Push(jobs)
  29. }()
  30. return categoryID
  31. }