Commit 23dc7d37 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[Metrics] small refactoring

parent 4b985c58
Pipeline #1090 failed with stage
...@@ -39,7 +39,7 @@ import Gargantext.Database.Query.Table.Node.Error (HasNodeError) ...@@ -39,7 +39,7 @@ import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata) import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import Gargantext.Database.Schema.Node (node_hyperdata) import Gargantext.Database.Schema.Node (node_hyperdata)
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Core.Text.Metrics (Scored(..)) import Gargantext.Core.Text.Metrics (Scored(..), {-normalizeGlobal,-} normalizeLocal)
import Gargantext.Core.Viz.Chart import Gargantext.Core.Viz.Chart
import Gargantext.Core.Viz.Types import Gargantext.Core.Viz.Types
import qualified Gargantext.Database.Action.Metrics as Metrics import qualified Gargantext.Database.Action.Metrics as Metrics
...@@ -106,8 +106,9 @@ updateScatter' cId maybeListId tabType maybeLimit = do ...@@ -106,8 +106,9 @@ updateScatter' cId maybeListId tabType maybeLimit = do
(ngs', scores) <- Metrics.getMetrics cId maybeListId tabType maybeLimit (ngs', scores) <- Metrics.getMetrics cId maybeListId tabType maybeLimit
let let
metrics = map (\(Scored t s1 s2) -> Metric t (log' 5 s1) (log' 2 s2) (listType t ngs')) scores metrics = map (\(Scored t s1 s2) -> Metric t s1 s2 (listType t ngs'))
log' n x = 1 + (if x <= 0 then 0 else log $ (10^(n::Int)) * x) -- $ normalizeGlobal
$ map normalizeLocal scores
listType t m = maybe (panic errorMsg) fst $ Map.lookup t m listType t m = maybe (panic errorMsg) fst $ Map.lookup t m
errorMsg = "API.Node.metrics: key absent" errorMsg = "API.Node.metrics: key absent"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment