From 52b91be870affb426c23d2014234fc00f8aea513 Mon Sep 17 00:00:00 2001 From: tijl Date: Mon, 26 Aug 2024 21:49:37 +0200 Subject: [PATCH] fixes --- go.mod | 8 ++++++ go.sum | 22 ++++++++++++++++ internal/apps/flags/handlers.go | 41 ++++++++++++++++++++---------- internal/apps/flags/main.go | 2 +- internal/handlers/routes.go | 1 + internal/handlers/stats.go | 30 ++++++++++++++++++++++ internal/queries/util.sql | 2 ++ internal/queries/util.sql.go | 21 +++++++++++++++ web/views/apps/flags/question.html | 4 +++ web/views/stats.html | 4 +++ 10 files changed, 120 insertions(+), 15 deletions(-) create mode 100644 internal/handlers/stats.go create mode 100644 internal/queries/util.sql create mode 100644 internal/queries/util.sql.go create mode 100644 web/views/stats.html diff --git a/go.mod b/go.mod index bc4c47e..62fa78a 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( github.com/andybalholm/brotli v1.1.0 // indirect github.com/enescakir/emoji v1.0.0 // indirect github.com/go-jose/go-jose/v4 v4.0.2 // indirect + github.com/go-ole/go-ole v1.2.6 // indirect github.com/gofiber/template v1.8.3 // indirect github.com/gofiber/utils v1.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect @@ -32,14 +33,21 @@ require ( github.com/jackc/puddle/v2 v2.2.1 // indirect github.com/klauspost/compress v1.17.9 // indirect github.com/kr/text v0.2.0 // indirect + github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect + github.com/shirou/gopsutil/v3 v3.24.5 // indirect + github.com/shoenig/go-m1cpu v0.1.6 // indirect + github.com/tklauser/go-sysconf v0.3.12 // indirect + github.com/tklauser/numcpus v0.6.1 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasthttp v1.55.0 // indirect github.com/valyala/tcplisten v1.0.0 // indirect + github.com/yusufpapurcu/wmi v1.2.4 // indirect go.uber.org/atomic v1.7.0 // indirect golang.org/x/crypto v0.25.0 // indirect golang.org/x/sync v0.7.0 // indirect diff --git a/go.sum b/go.sum index 0887ef2..d073d00 100644 --- a/go.sum +++ b/go.sum @@ -25,6 +25,8 @@ github.com/enescakir/emoji v1.0.0 h1:W+HsNql8swfCQFtioDGDHCHri8nudlK1n5p2rHCJoog github.com/enescakir/emoji v1.0.0/go.mod h1:Bt1EKuLnKDTYpLALApstIkAjdDrS/8IAgTkKp+WKFD0= github.com/go-jose/go-jose/v4 v4.0.2 h1:R3l3kkBds16bO7ZFAEEcofK0MkrAJt3jlJznWZG0nvk= github.com/go-jose/go-jose/v4 v4.0.2/go.mod h1:WVf9LFMHh/QVrmqrOfqun0C45tMe3RoiKJMPvgWwLfY= +github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY= +github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gofiber/contrib/fiberzerolog v1.0.2 h1:LMa/luarQVeINoRwZLHtLQYepLPDIwUNB5OmdZKk+s8= github.com/gofiber/contrib/fiberzerolog v1.0.2/go.mod h1:aTPsgArSgxRWcUeJ/K6PiICz3mbQENR1QOR426QwOoQ= @@ -40,6 +42,7 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-migrate/migrate/v4 v4.17.1 h1:4zQ6iqL6t6AiItphxJctQb3cFqWiSpMnX7wLTPnnYO4= github.com/golang-migrate/migrate/v4 v4.17.1/go.mod h1:m8hinFyWBn0SA4QKHuKh175Pm9wjmxj3S2Mia7dbXzM= +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -67,6 +70,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= +github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= @@ -87,6 +92,8 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw= +github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.4 h1:8TfxU8dW6PdqD27gjM8MVNuicgxIjxpm4K7x4jp8sis= github.com/rivo/uniseg v0.4.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -95,11 +102,19 @@ github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99 github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8= github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI= +github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk= +github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM= +github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU= +github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI= +github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk= +github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasthttp v1.55.0 h1:Zkefzgt6a7+bVKHnu/YaYSOPfNYNisSVBo/unVCf8k8= @@ -110,6 +125,8 @@ github.com/yuin/goldmark v1.7.4 h1:BDXOHExt+A7gwPCJgPIIq7ENvceR7we7rOS9TNoLZeg= github.com/yuin/goldmark v1.7.4/go.mod h1:uzxRWxtg69N339t3louHJ7+O03ezfj6PlliRlaOzY1E= github.com/yuin/goldmark-meta v1.1.0 h1:pWw+JLHGZe8Rk0EGsMVssiNb/AaPMHfSRszZeUeiOUc= github.com/yuin/goldmark-meta v1.1.0/go.mod h1:U4spWENafuA7Zyg+Lj5RqK/MF+ovMYtBvXi1lBb2VP0= +github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0= +github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= @@ -122,8 +139,12 @@ golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs= golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= @@ -131,6 +152,7 @@ golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/internal/apps/flags/handlers.go b/internal/apps/flags/handlers.go index fe5ede5..2781fc6 100644 --- a/internal/apps/flags/handlers.go +++ b/internal/apps/flags/handlers.go @@ -12,6 +12,7 @@ import ( "git.tijl.dev/tijl/tijl.dev-core/internal/utils" "git.tijl.dev/tijl/tijl.dev-core/modules/db" "git.tijl.dev/tijl/tijl.dev-core/modules/i18n" + log "git.tijl.dev/tijl/tijl.dev-core/modules/logger" "git.tijl.dev/tijl/tijl.dev-core/modules/web" "github.com/enescakir/emoji" "github.com/gofiber/fiber/v2" @@ -20,6 +21,16 @@ import ( const flagSessionCookie string = "app_flags_game_session" +type NullableUUID struct { + uuid.UUID + valid bool +} + +type NullableString struct { + String string + valid bool +} + func answerHandler(c *fiber.Ctx) error { gameId, err := uuid.Parse(c.Cookies(flagSessionCookie)) @@ -66,19 +77,18 @@ func answerHandler(c *fiber.Ctx) error { return err } - return questionHandler(c, NewGameUUID{}) + if answer == correctAnswer { + return questionHandler(c, NullableUUID{}, NullableString{}) + } else { + return questionHandler(c, NullableUUID{}, NullableString{valid: true, String: answer}) + } } -type NewGameUUID struct { - uuid.UUID - used bool -} - -func questionHandler(c *fiber.Ctx, newGame NewGameUUID) error { +func questionHandler(c *fiber.Ctx, newGame NullableUUID, prevError NullableString) error { var gameId uuid.UUID var err error - if newGame.used { + if newGame.valid { gameId = newGame.UUID } else { gameId, err = uuid.Parse(c.Cookies(flagSessionCookie)) @@ -138,6 +148,8 @@ func questionHandler(c *fiber.Ctx, newGame NewGameUUID) error { data["Answers"] = shuffledAnswers data["Flag"] = flag data["Errors"] = gameSession.QuestionsErrors + log.Debug().Msg(prevError.String) + data["PreviousError"] = prevError.String return c.Render("apps/flags/question", data, "layouts/base") } @@ -149,7 +161,7 @@ func sharedGameHandler(c *fiber.Ctx) error { return err } - return setupGame(c, data.Tags, int(data.Questions), int(data.Seconds), true, data.GameSeed) + return setupGame(c, data.Tags, int(data.Questions), int(data.Seconds), NullableUUID{valid: true, UUID: data.GameSeed}) } func startNewGameHandler(c *fiber.Ctx) error { @@ -186,7 +198,7 @@ func startNewGameHandler(c *fiber.Ctx) error { return createSharedGameData(c, selectedTags, maxQuestions, seconds) } - return setupGame(c, selectedTags, maxQuestions, seconds, false, uuid.UUID{}) + return setupGame(c, selectedTags, maxQuestions, seconds, NullableUUID{}) } func createSharedGameData(c *fiber.Ctx, tags []string, maxQuestions int, seconds int) error { @@ -196,6 +208,7 @@ func createSharedGameData(c *fiber.Ctx, tags []string, maxQuestions int, seconds Tags: tags, Questions: int32(maxQuestions), Seconds: int32(seconds), + GameSeed: uuid.New(), }) if err != nil { return err @@ -207,7 +220,7 @@ func createSharedGameData(c *fiber.Ctx, tags []string, maxQuestions int, seconds return c.Render("apps/flags/shared", data, "layouts/base") } -func setupGame(c *fiber.Ctx, tags []string, maxQuestions int, seconds int, useGameSeed bool, gameSeed uuid.UUID) error { +func setupGame(c *fiber.Ctx, tags []string, maxQuestions int, seconds int, gameSeed NullableUUID) error { var Quid = sql.NullString{} uid, err := user.GetSession(c) if err == nil { @@ -223,8 +236,8 @@ func setupGame(c *fiber.Ctx, tags []string, maxQuestions int, seconds int, useGa GameSeed: uuid.New(), } - if useGameSeed { - createGameParams.GameSeed = gameSeed + if gameSeed.valid { + createGameParams.GameSeed = gameSeed.UUID } gameID, err := db.Queries.AppFlagsCreateGameWithSeed(context.TODO(), createGameParams) @@ -238,7 +251,7 @@ func setupGame(c *fiber.Ctx, tags []string, maxQuestions int, seconds int, useGa //Secure: true, }) - return questionHandler(c, NewGameUUID{used: true, UUID: gameID}) + return questionHandler(c, NullableUUID{valid: true, UUID: gameID}, NullableString{}) } func gameEndHandler(c *fiber.Ctx) error { diff --git a/internal/apps/flags/main.go b/internal/apps/flags/main.go index f87e4de..b510dfa 100644 --- a/internal/apps/flags/main.go +++ b/internal/apps/flags/main.go @@ -33,7 +33,7 @@ func Setup() { a.Get("/app/flags", func(c *fiber.Ctx) error { if c.Cookies("app_flags_game_session") != "" { - return questionHandler(c, NewGameUUID{}) + return questionHandler(c, NullableUUID{}, NullableString{}) } else { return gameStartHandler(c) } diff --git a/internal/handlers/routes.go b/internal/handlers/routes.go index 7860459..433ce3f 100644 --- a/internal/handlers/routes.go +++ b/internal/handlers/routes.go @@ -52,6 +52,7 @@ func routes(app *fiber.App) { app.Get("/loggedin", loggedinHandler) app.Get("/account", accountHandler) app.Get("/logout", logoutHandler) + app.Get("/stats", stats) app.Get("/settings", settingsHandler) app.Get("/auth", authHandler) diff --git a/internal/handlers/stats.go b/internal/handlers/stats.go new file mode 100644 index 0000000..fdae787 --- /dev/null +++ b/internal/handlers/stats.go @@ -0,0 +1,30 @@ +package handlers + +import ( + "context" + "runtime" + + "git.tijl.dev/tijl/tijl.dev-core/internal/user" + "git.tijl.dev/tijl/tijl.dev-core/modules/db" + "git.tijl.dev/tijl/tijl.dev-core/modules/i18n" + "git.tijl.dev/tijl/tijl.dev-core/modules/web" + "github.com/gofiber/fiber/v2" +) + +func stats(c *fiber.Ctx) error { + _, err := user.GetSession(c) + if err != nil { + return c.Next() + } + + dbsize, err := db.Queries.GetPGSize(context.TODO()) + if err != nil { + return err + } + + data := *web.Common(c) + data["Title"] = i18n.Translate(c, "home") + data["DatabaseSize"] = dbsize + data["Goroutines"] = runtime.NumGoroutine() + return c.Render("stats", data, "layouts/base") +} diff --git a/internal/queries/util.sql b/internal/queries/util.sql new file mode 100644 index 0000000..b58906a --- /dev/null +++ b/internal/queries/util.sql @@ -0,0 +1,2 @@ +-- name: GetPGSize :one +SELECT pg_size_pretty(pg_database_size('tijldev')) AS database_size; diff --git a/internal/queries/util.sql.go b/internal/queries/util.sql.go new file mode 100644 index 0000000..a5cf809 --- /dev/null +++ b/internal/queries/util.sql.go @@ -0,0 +1,21 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.27.0 +// source: util.sql + +package queries + +import ( + "context" +) + +const getPGSize = `-- name: GetPGSize :one +SELECT pg_size_pretty(pg_database_size('tijldev')) AS database_size +` + +func (q *Queries) GetPGSize(ctx context.Context) (string, error) { + row := q.db.QueryRowContext(ctx, getPGSize) + var database_size string + err := row.Scan(&database_size) + return database_size, err +} diff --git a/web/views/apps/flags/question.html b/web/views/apps/flags/question.html index b09f73c..40b8613 100644 --- a/web/views/apps/flags/question.html +++ b/web/views/apps/flags/question.html @@ -23,7 +23,11 @@
+ {{if eq . $.PreviousError}} + + {{else}} + {{end}}
{{end}} diff --git a/web/views/stats.html b/web/views/stats.html new file mode 100644 index 0000000..9aad876 --- /dev/null +++ b/web/views/stats.html @@ -0,0 +1,4 @@ +
+
DatabaseSize: {{.DatabaseSize}}
+
Goroutines: {{.Goroutines}}
+