parent
74b69a4c7c
commit
ec47106c26
4 changed files with 20 additions and 27 deletions
3
go.mod
3
go.mod
|
@ -5,12 +5,9 @@ module miniflux.app
|
|||
require (
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/coreos/go-oidc v2.2.1+incompatible
|
||||
github.com/felixge/httpsnoop v1.0.3 // indirect
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
|
||||
github.com/golang/gddo v0.0.0-20210115222349-20d68f94ee1f // indirect
|
||||
github.com/gorilla/mux v1.8.0
|
||||
github.com/lib/pq v1.10.7
|
||||
github.com/mitchellh/go-server-timing v1.0.2-0.20201108055052-feb680ab92c2
|
||||
github.com/pquerna/cachecontrol v0.0.0-20180517163645-1555304b9b35 // indirect
|
||||
github.com/prometheus/client_golang v1.13.0
|
||||
github.com/rylans/getlang v0.0.0-20200505200108-4c3188ff8a2d
|
||||
|
|
8
go.sum
8
go.sum
|
@ -84,9 +84,6 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF
|
|||
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/felixge/httpsnoop v1.0.0/go.mod h1:3+D9sFq0ahK/JeJPhCBUV1xlf4/eIYrUQaxulT0VzX8=
|
||||
github.com/felixge/httpsnoop v1.0.3 h1:s/nj+GCswXYzN5v2DpNMuMQYe+0DDwt5WVCU6CWBdXk=
|
||||
github.com/felixge/httpsnoop v1.0.3/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fsnotify/fsnotify v1.4.3-0.20170329110642-4da3e2cfbabc/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
|
||||
|
@ -110,9 +107,6 @@ github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible h1:2cauKuaEL
|
|||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible/go.mod h1:qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
|
||||
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4=
|
||||
github.com/golang/gddo v0.0.0-20180823221919-9d8ff1c67be5/go.mod h1:xEhNfoBDX1hzLm2Nf80qUvZ2sVwoMZ8d6IE2SrsQfh4=
|
||||
github.com/golang/gddo v0.0.0-20210115222349-20d68f94ee1f h1:16RtHeWGkJMc80Etb8RPCcKevXGldr57+LOyZt8zOlg=
|
||||
github.com/golang/gddo v0.0.0-20210115222349-20d68f94ee1f/go.mod h1:ijRvpgDJDI262hYq/IQVYgf8hd8IHUs93Ol0kvMBAx4=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
|
@ -224,8 +218,6 @@ github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m
|
|||
github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-server-timing v1.0.2-0.20201108055052-feb680ab92c2 h1:9kYRAm87/M5VL+HWegDGIorBWDiErrZrksLKTJBF2IQ=
|
||||
github.com/mitchellh/go-server-timing v1.0.2-0.20201108055052-feb680ab92c2/go.mod h1:8mKJVJkyMI20ifXXO0zlV3sh3FrtjvltAeBqz38clBE=
|
||||
github.com/mitchellh/mapstructure v0.0.0-20170523030023-d0303fe80992/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
|
|
5
ui/ui.go
5
ui/ui.go
|
@ -7,14 +7,12 @@ package ui // import "miniflux.app/ui"
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/logger"
|
||||
"miniflux.app/storage"
|
||||
"miniflux.app/template"
|
||||
"miniflux.app/worker"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
servertiming "github.com/mitchellh/go-server-timing"
|
||||
)
|
||||
|
||||
// Serve declares all routes for the user interface.
|
||||
|
@ -31,9 +29,6 @@ func Serve(router *mux.Router, store *storage.Storage, pool *worker.Pool) {
|
|||
uiRouter := router.NewRoute().Subrouter()
|
||||
uiRouter.Use(middleware.handleUserSession)
|
||||
uiRouter.Use(middleware.handleAppSession)
|
||||
uiRouter.Use(func(h http.Handler) http.Handler {
|
||||
return servertiming.Middleware(h, &servertiming.MiddlewareOpts{DisableHeaders: !config.Opts.HasServerTimingHeader()})
|
||||
})
|
||||
uiRouter.StrictSlash(true)
|
||||
|
||||
// Static assets.
|
||||
|
|
|
@ -5,21 +5,21 @@
|
|||
package ui // import "miniflux.app/ui"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"miniflux.app/config"
|
||||
"miniflux.app/http/request"
|
||||
"miniflux.app/http/response/html"
|
||||
"miniflux.app/http/route"
|
||||
"miniflux.app/model"
|
||||
"miniflux.app/ui/session"
|
||||
"miniflux.app/ui/view"
|
||||
|
||||
servertiming "github.com/mitchellh/go-server-timing"
|
||||
)
|
||||
|
||||
func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
|
||||
timing := servertiming.FromContext(r.Context())
|
||||
prep := timing.NewMetric("pre_processing").Start()
|
||||
beginPreProcessing := time.Now()
|
||||
|
||||
sess := session.New(h.store, request.SessionID(r))
|
||||
view := view.New(h.tpl, r, sess)
|
||||
|
@ -30,7 +30,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
|
|||
return
|
||||
}
|
||||
|
||||
m := timing.NewMetric("sql_count_unread_entries").Start()
|
||||
beginSqlCountUnreadEntries := time.Now()
|
||||
offset := request.QueryIntParam(r, "offset", 0)
|
||||
builder := h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
|
@ -40,13 +40,13 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
|
|||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
m.Stop()
|
||||
finishSqlCountUnreadEntries := time.Now()
|
||||
|
||||
if offset >= countUnread {
|
||||
offset = 0
|
||||
}
|
||||
|
||||
m = timing.NewMetric("sql_fetch_unread_entries").Start()
|
||||
beginSqlFetchUnreadEntries := time.Now()
|
||||
builder = h.store.NewEntryQueryBuilder(user.ID)
|
||||
builder.WithStatus(model.EntryStatusUnread)
|
||||
builder.WithOrder(user.EntryOrder)
|
||||
|
@ -59,7 +59,7 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
|
|||
html.ServerError(w, r, err)
|
||||
return
|
||||
}
|
||||
m.Stop()
|
||||
finishSqlFetchUnreadEntries := time.Now()
|
||||
|
||||
view.Set("entries", entries)
|
||||
view.Set("pagination", getPagination(route.Path(h.router, "unread"), countUnread, offset, user.EntriesPerPage))
|
||||
|
@ -69,11 +69,20 @@ func (h *handler) showUnreadPage(w http.ResponseWriter, r *http.Request) {
|
|||
view.Set("countErrorFeeds", h.store.CountUserFeedsWithErrors(user.ID))
|
||||
view.Set("hasSaveEntry", h.store.HasSaveEntry(user.ID))
|
||||
|
||||
prep.Stop()
|
||||
finishPreProcessing := time.Now()
|
||||
|
||||
m = timing.NewMetric("template_rendering").Start()
|
||||
beginTemplateRendering := time.Now()
|
||||
render := view.Render("unread_entries")
|
||||
m.Stop()
|
||||
finishTemplateRendering := time.Now()
|
||||
|
||||
if config.Opts.HasServerTimingHeader() {
|
||||
w.Header().Set("Server-Timing", fmt.Sprintf("pre_processing;dur=%d,sql_count_unread_entries;dur=%d,sql_fetch_unread_entries;dur=%d,template_rendering;dur=%d",
|
||||
finishPreProcessing.Sub(beginPreProcessing).Milliseconds(),
|
||||
finishSqlCountUnreadEntries.Sub(beginSqlCountUnreadEntries).Milliseconds(),
|
||||
finishSqlFetchUnreadEntries.Sub(beginSqlFetchUnreadEntries).Milliseconds(),
|
||||
finishTemplateRendering.Sub(beginTemplateRendering).Milliseconds(),
|
||||
))
|
||||
}
|
||||
|
||||
html.OK(w, r, render)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue