From 9ce745c72586e4888936087aedf558e6b1e91262 Mon Sep 17 00:00:00 2001 From: Pere Lev Date: Sat, 6 Jul 2024 12:53:31 +0300 Subject: [PATCH] UI, DB: Store debug reports in DB and link to them from navbar --- migrations/648_2024-07-06_report.model | 5 +++++ src/Vervis/Application.hs | 7 +------ src/Vervis/Foundation.hs | 2 -- src/Vervis/Handler/Client.hs | 11 +++++------ src/Vervis/Migration.hs | 2 ++ src/Vervis/Migration/Entities.hs | 6 ++++++ src/Vervis/Web/Actor.hs | 23 ++++++++--------------- templates/default-layout.hamlet | 7 +++++++ th/models | 6 ++++++ th/routes | 2 +- 10 files changed, 41 insertions(+), 30 deletions(-) create mode 100644 migrations/648_2024-07-06_report.model diff --git a/migrations/648_2024-07-06_report.model b/migrations/648_2024-07-06_report.model new file mode 100644 index 0000000..3d66e7f --- /dev/null +++ b/migrations/648_2024-07-06_report.model @@ -0,0 +1,5 @@ +Report + time UTCTime + message Text + types ListOfByteStrings + body ByteString diff --git a/src/Vervis/Application.hs b/src/Vervis/Application.hs index 1ae4bbc..1430e02 100644 --- a/src/Vervis/Application.hs +++ b/src/Vervis/Application.hs @@ -1,6 +1,6 @@ {- This file is part of Vervis. - - - Written in 2016, 2018, 2019, 2020, 2022, 2023 + - Written in 2016, 2018, 2019, 2020, 2022, 2023, 2024 - by fr33domlover . - - ♡ Copying is an act of love. Please copy, reuse and share. @@ -202,11 +202,6 @@ makeFoundation appSettings = do appActorFetchShare <- newResultShare actorFetchShareAction - appActivities <- - case appInboxDebugReportLength appSettings of - Nothing -> return Nothing - Just n -> Just . (n,) <$> newTVarIO mempty - -- We need a log function to create a connection pool. We need a connection -- pool to create our foundation. And we need our foundation to get a -- logging function. To get out of this loop, we initially create a diff --git a/src/Vervis/Foundation.hs b/src/Vervis/Foundation.hs index 0efeb6a..6aabb23 100644 --- a/src/Vervis/Foundation.hs +++ b/src/Vervis/Foundation.hs @@ -137,8 +137,6 @@ data App = App , appTheater :: Theater , appEnv :: Env , appPersonLauncher :: MVar (PersonId, MVar Bool) - - , appActivities :: Maybe (Int, TVar (Vector ActivityReport)) } -- Aliases for the routes file, because it doesn't like spaces in path piece diff --git a/src/Vervis/Handler/Client.hs b/src/Vervis/Handler/Client.hs index 4f743b8..6a06880 100644 --- a/src/Vervis/Handler/Client.hs +++ b/src/Vervis/Handler/Client.hs @@ -94,7 +94,7 @@ import Yesod.Persist.Core import qualified Data.ByteString.Char8 as BC import qualified Data.HashMap.Strict as M import qualified Data.Text as T -import qualified Data.Text.Lazy.Encoding as TLE +import qualified Data.Text.Encoding as TE import qualified Database.Esqueleto as E import Database.Persist.JSON @@ -792,8 +792,7 @@ postPublishR = do getInboxDebugR :: Handler Html getInboxDebugR = do - acts <- - liftIO . readTVarIO . snd =<< maybe notFound return =<< getsYesod appActivities + acts <- runDB $ selectList [] [Desc ReportId, LimitTo 30] defaultLayout [whamlet|

@@ -805,14 +804,14 @@ getInboxDebugR = do result. Activities that aren't understood or their processing fails get listed here too, with a report of what exactly happened. -

Last 10 activities posted: +

Last 30 activities posted: