mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 09:22:43 +03:00
server: Include number of enum tables in metrics
This commit is contained in:
parent
c48904551e
commit
78ec906794
@ -58,6 +58,7 @@ data Metrics
|
||||
= Metrics
|
||||
{ _mtTables :: !Int
|
||||
, _mtViews :: !Int
|
||||
, _mtEnumTables :: !Int
|
||||
, _mtRelationships :: !RelationshipMetric
|
||||
, _mtPermissions :: !PermissionMetric
|
||||
, _mtEventTriggers :: !Int
|
||||
@ -128,12 +129,13 @@ runTelemetry (Logger logger) manager cacheRef dbId instanceId = do
|
||||
|
||||
computeMetrics :: SchemaCache -> Metrics
|
||||
computeMetrics sc =
|
||||
let nTables = Map.size $ Map.filter (isNothing . _tiViewInfo) usrTbls
|
||||
nViews = Map.size $ Map.filter (isJust . _tiViewInfo) usrTbls
|
||||
allRels = join $ Map.elems $ Map.map relsOfTbl usrTbls
|
||||
let nTables = countUserTables (isNothing . _tiViewInfo)
|
||||
nViews = countUserTables (isJust . _tiViewInfo)
|
||||
nEnumTables = countUserTables (isJust . _tiEnumValues)
|
||||
allRels = join $ Map.elems $ Map.map relsOfTbl userTables
|
||||
(manualRels, autoRels) = partition riIsManual allRels
|
||||
relMetrics = RelationshipMetric (length manualRels) (length autoRels)
|
||||
rolePerms = join $ Map.elems $ Map.map permsOfTbl usrTbls
|
||||
rolePerms = join $ Map.elems $ Map.map permsOfTbl userTables
|
||||
nRoles = length $ nub $ fst <$> rolePerms
|
||||
allPerms = snd <$> rolePerms
|
||||
insPerms = calcPerms _permIns allPerms
|
||||
@ -143,14 +145,15 @@ computeMetrics sc =
|
||||
permMetrics =
|
||||
PermissionMetric selPerms insPerms updPerms delPerms nRoles
|
||||
evtTriggers = Map.size $ Map.filter (not . Map.null)
|
||||
$ Map.map _tiEventTriggerInfoMap usrTbls
|
||||
$ Map.map _tiEventTriggerInfoMap userTables
|
||||
rmSchemas = Map.size $ scRemoteSchemas sc
|
||||
funcs = Map.size $ Map.filter (not . fiSystemDefined) $ scFunctions sc
|
||||
|
||||
in Metrics nTables nViews relMetrics permMetrics evtTriggers rmSchemas funcs
|
||||
in Metrics nTables nViews nEnumTables relMetrics permMetrics evtTriggers rmSchemas funcs
|
||||
|
||||
where
|
||||
usrTbls = Map.filter (not . _tiSystemDefined) $ scTables sc
|
||||
userTables = Map.filter (not . _tiSystemDefined) $ scTables sc
|
||||
countUserTables predicate = length . filter predicate $ Map.elems userTables
|
||||
|
||||
calcPerms :: (RolePermInfo -> Maybe a) -> [RolePermInfo] -> Int
|
||||
calcPerms fn perms = length $ catMaybes $ map fn perms
|
||||
|
Loading…
Reference in New Issue
Block a user