From cb2f1ae0648b01749fc23bfa86703aebf09535a9 Mon Sep 17 00:00:00 2001 From: outfoxxed <outfoxxed@outfoxxed.me> Date: Mon, 10 Feb 2025 22:50:37 -0800 Subject: [PATCH] require client to use the same path format as plausible (/ ended) --- src/PlausibleQuery.hs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/PlausibleQuery.hs b/src/PlausibleQuery.hs index 4c999a2..c698ffc 100644 --- a/src/PlausibleQuery.hs +++ b/src/PlausibleQuery.hs @@ -27,16 +27,9 @@ instance FromJSON MRResult where parseMetricsResponse :: MetricsResponse -> Either String (Map String Int) parseMetricsResponse MetricsResponse { results = r } = Map.fromList <$> mapM parseResult r where parseResult :: MRResult -> Either String (String, Int) - parseResult MRResult { metrics = [count], dimensions = [path] } = Right (removeTrailingSlash path, count) + parseResult MRResult { metrics = [count], dimensions = [path] } = Right (path, count) parseResult result = Left $ "Could not parse result: " ++ show result - removeTrailingSlash "/" = "/" - removeTrailingSlash xs = removeTrailingSlash' xs - - removeTrailingSlash' "" = "" - removeTrailingSlash' "/" = "" - removeTrailingSlash' (x:xs) = x : removeTrailingSlash' xs - queryPageviews :: C.Config -> IO (Either String (Map String Int)) queryPageviews config = do request' <- H.parseRequest $ "POST " ++ C.queryUrl (C.plausible config)