[phylo] minutely phylo works now

parent d3692c15
Pipeline #7834 failed with stages
in 15 minutes and 2 seconds
......@@ -170,12 +170,13 @@ fileToList parser path =
-- Config time parameters to label
timeToLabel :: PhyloConfig -> [Char]
timeToLabel config = case (timeUnit config) of
Epoch p s f -> ("time_epochs" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Year p s f -> ("time_years" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Month p s f -> ("time_months" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Week p s f -> ("time_weeks" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Day p s f -> ("time_days" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Hour _p _s _f -> panicTrace "hours not implemented"
Epoch p s f -> ("time_epochs" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Year p s f -> ("time_years" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Month p s f -> ("time_months" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Week p s f -> ("time_weeks" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Day p s f -> ("time_days" <> "_" <> (show p) <> "_" <> (show s) <> "_" <> (show f))
Hour _p _s _f -> panicTrace "hours not implemented"
Minute _p _s _f -> panicTrace "minutes not implemented"
seaToLabel :: PhyloConfig -> [Char]
......
......@@ -10,8 +10,6 @@ Portability : POSIX
-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module Gargantext.API.Context
where
......@@ -21,7 +19,7 @@ import Gargantext.API.Admin.Auth.Types (PathId(..), AuthenticatedUser)
import Gargantext.API.Prelude (IsGargServer)
import Gargantext.API.Routes.Named.Context qualified as Named
import Gargantext.Database.Admin.Types.Node (ContextId, contextId2NodeId)
import Gargantext.Database.Prelude
import Gargantext.Database.Prelude ( JSONB, runDBQuery )
import Gargantext.Database.Query.Table.Context (getContextWith)
import Gargantext.Prelude
import Servant.Server.Generic (AsServerT)
......
......@@ -139,6 +139,10 @@ data TimeUnit =
{ _hour_period :: Int
, _hour_step :: Int
, _hour_matchingFrame :: Int }
| Minute
{ _minute_period :: Int
, _minute_step :: Int
, _minute_matchingFrame :: Int }
deriving (Show,Generic,Eq,NFData,ToExpr)
instance ToSchema TimeUnit where
......
......@@ -207,19 +207,23 @@ toDays y m d = fromIntegral
$ diffDays (fromGregorian y m d) (fromGregorian 0001 1 1)
toHours :: UTCTimeR -> Date
toHours utcTimeR = floor diffSeconds `div` 3600
toHours utcTimeR = toMinutes utcTimeR `div` 60
toMinutes :: UTCTimeR -> Date
toMinutes utcTimeR = floor diffSeconds `div` 60
where
diffSeconds = diffUTCTime (toUTCTime utcTimeR) (toUTCTime defUTCTimeR)
-- | This must be in accordance with frontend's 'G.C.PE.Types' -> 'parseNodeDate'
toPhyloDate :: UTCTimeR -> TimeUnit -> Date
toPhyloDate utcTimeR@(UTCTimeR { .. }) tu = case tu of
Year {} -> year
Month {} -> toMonths (Prelude.toInteger year) month day
Week {} -> div (toDays (Prelude.toInteger year) month day) 7
Day {} -> toDays (Prelude.toInteger year) month day
Hour {} -> toHours utcTimeR
_ -> panic "[G.C.V.P.API.Tools] toPhyloDate"
Year {} -> year
Month {} -> toMonths (Prelude.toInteger year) month day
Week {} -> div (toDays (Prelude.toInteger year) month day) 7
Day {} -> toDays (Prelude.toInteger year) month day
Hour {} -> toHours utcTimeR
Minute {} -> toMinutes utcTimeR
_ -> panic "[G.C.V.P.API.Tools] toPhyloDate"
toPhyloDate' :: UTCTimeR -> TimeUnit -> Text
toPhyloDate' (UTCTimeR { .. }) (Epoch {}) = pack $ show $ posixSecondsToUTCTime $ fromIntegral year
......
......@@ -170,12 +170,13 @@ toLstDate ds = snd
getTimeScale :: Phylo -> [Char]
getTimeScale p = case timeUnit $ getConfig p of
Epoch {} -> "epoch"
Year {} -> "year"
Month {} -> "month"
Week {} -> "week"
Day {} -> "day"
Hour {} -> "hour"
Epoch {} -> "epoch"
Year {} -> "year"
Month {} -> "month"
Week {} -> "week"
Day {} -> "day"
Hour {} -> "hour"
Minute {} -> "minute"
-- | Get a regular & ascendante timeScale from a given list of dates
......@@ -187,12 +188,13 @@ toTimeScale dates step =
getTimeStep :: TimeUnit -> Int
getTimeStep time = case time of
Epoch { .. } -> _epoch_step
Year { .. } -> _year_step
Month { .. } -> _month_step
Week { .. } -> _week_step
Day { .. } -> _day_step
Hour { .. } -> _hour_step
Epoch { .. } -> _epoch_step
Year { .. } -> _year_step
Month { .. } -> _month_step
Week { .. } -> _week_step
Day { .. } -> _day_step
Hour { .. } -> _hour_step
Minute { .. } -> _minute_step
getTimePeriod :: TimeUnit -> Int
getTimePeriod time = case time of
......@@ -202,6 +204,7 @@ getTimePeriod time = case time of
Week { .. } -> _week_period
Day { .. } -> _day_period
Hour { .. } -> _hour_period
Minute { .. } -> _minute_period
getTimeFrame :: TimeUnit -> Int
getTimeFrame time = case time of
......@@ -211,6 +214,7 @@ getTimeFrame time = case time of
Week { .. } -> _week_matchingFrame
Day { .. } -> _day_matchingFrame
Hour { .. } -> _hour_matchingFrame
Minute { .. } -> _minute_matchingFrame
-------------
-- | Fis | --
......
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