Commit bb43a634 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Fix corner case of indexDates'

It's not enough to check that the list is empty, we also need to check
that we have some data to begin with, i.e. we need to skip calling
`toFstDate` or `toLstDate` if we have a list of empty strings.
parent 50d199ba
...@@ -241,10 +241,10 @@ clusterToGroup fis pId pId' lvl idx coocs rootsCount = PhyloGroup pId pId' lvl i ...@@ -241,10 +241,10 @@ clusterToGroup fis pId pId' lvl idx coocs rootsCount = PhyloGroup pId pId' lvl i
indexDates' :: Map (Date,Date) [Document] -> Map (Date,Date) (Text,Text) indexDates' :: Map (Date,Date) [Document] -> Map (Date,Date) (Text,Text)
indexDates' m = map (\docs -> indexDates' m = map (\docs ->
let ds = map (\d -> date' d) docs let ds = map (\d -> date' d) docs
f = if (null ds) f = if (null ds || all T.null ds)
then "" then ""
else toFstDate ds else toFstDate ds
l = if (null ds) l = if (null ds || all T.null ds)
then "" then ""
else toLstDate ds else toLstDate ds
in (f,l)) m in (f,l)) m
......
...@@ -30,7 +30,6 @@ import Data.Vector (Vector, elemIndex) ...@@ -30,7 +30,6 @@ import Data.Vector (Vector, elemIndex)
import Data.Vector qualified as Vector import Data.Vector qualified as Vector
import Gargantext.Core.Viz.Phylo import Gargantext.Core.Viz.Phylo
import Gargantext.Prelude hiding (empty) import Gargantext.Prelude hiding (empty)
import Prelude (read)
import Text.Printf import Text.Printf
------------ ------------
...@@ -160,7 +159,7 @@ toFstDate ds = snd ...@@ -160,7 +159,7 @@ toFstDate ds = snd
$ head' "firstDate" $ head' "firstDate"
$ sortOn fst $ sortOn fst
$ map (\d -> $ map (\d ->
let d' = read (filter (\c -> notElem c ['U','T','C',' ',':','-']) $ unpack d)::Int let d' = fromMaybe (error "toFstDate") $ readMaybe (filter (\c -> notElem c ['U','T','C',' ',':','-']) $ unpack d)::Int
in (d',d)) ds in (d',d)) ds
toLstDate :: [Text] -> Text toLstDate :: [Text] -> Text
...@@ -169,7 +168,7 @@ toLstDate ds = snd ...@@ -169,7 +168,7 @@ toLstDate ds = snd
$ reverse $ reverse
$ sortOn fst $ sortOn fst
$ map (\d -> $ map (\d ->
let d' = read (filter (\c -> notElem c ['U','T','C',' ',':','-']) $ unpack d)::Int let d' = fromMaybe (error "toLstDate") $ readMaybe (filter (\c -> notElem c ['U','T','C',' ',':','-']) $ unpack d)::Int
in (d',d)) ds in (d',d)) ds
......
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