require client to use the same path format as plausible (/ ended)
This commit is contained in:
		
							parent
							
								
									7a7a3b65f8
								
							
						
					
					
						commit
						cb2f1ae064
					
				
					 1 changed files with 1 additions and 8 deletions
				
			
		| 
						 | 
					@ -27,16 +27,9 @@ instance FromJSON MRResult where
 | 
				
			||||||
parseMetricsResponse :: MetricsResponse -> Either String (Map String Int)
 | 
					parseMetricsResponse :: MetricsResponse -> Either String (Map String Int)
 | 
				
			||||||
parseMetricsResponse MetricsResponse { results = r } = Map.fromList <$> mapM parseResult r
 | 
					parseMetricsResponse MetricsResponse { results = r } = Map.fromList <$> mapM parseResult r
 | 
				
			||||||
  where parseResult :: MRResult -> Either String (String, Int)
 | 
					  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
 | 
					        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 :: C.Config -> IO (Either String (Map String Int))
 | 
				
			||||||
queryPageviews config = do
 | 
					queryPageviews config = do
 | 
				
			||||||
  request' <- H.parseRequest $ "POST " ++ C.queryUrl (C.plausible config)
 | 
					  request' <- H.parseRequest $ "POST " ++ C.queryUrl (C.plausible config)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue