[phylo] minutely phylo works now

parent 76597f84
Pipeline #7835 passed with stages
in 26 minutes and 6 seconds
...@@ -5,6 +5,7 @@ module Gargantext.Components.Document.Layout ...@@ -5,6 +5,7 @@ module Gargantext.Components.Document.Layout
import Gargantext.Prelude import Gargantext.Prelude
import Data.Array as A import Data.Array as A
import Data.Foldable (fold)
import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe) import Data.Maybe (Maybe(..), fromMaybe, isJust, maybe)
import Data.Set as Set import Data.Set as Set
import Data.String as String import Data.String as String
...@@ -27,6 +28,7 @@ import Gargantext.Hooks.Loader (useLoader) ...@@ -27,6 +28,7 @@ import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Sessions (Session) import Gargantext.Sessions (Session)
import Gargantext.Utils as U import Gargantext.Utils as U
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Partial.Unsafe (unsafeCrashWith)
import Reactix as R import Reactix as R
import Reactix.DOM.HTML as H import Reactix.DOM.HTML as H
import Record as Record import Record as Record
...@@ -409,8 +411,51 @@ layoutWithContextNgramsCpt = here.component "layoutWithContextNgrams" cpt ...@@ -409,8 +411,51 @@ layoutWithContextNgramsCpt = here.component "layoutWithContextNgrams" cpt
publicationDate :: Document -> String publicationDate :: Document -> String
publicationDate (Document { publication_year: Nothing }) = "" publicationDate (Document { publication_year: Nothing }) = ""
publicationDate (Document { publication_year: Just py, publication_month: Nothing }) = U.zeroPad 2 py publicationDate (Document { publication_year: Just py, publication_month: Nothing }) = U.zeroPad 2 py
publicationDate (Document { publication_year: Just py, publication_month: Just pm, publication_day: Nothing }) = (U.zeroPad 2 py) <> "-" <> (U.zeroPad 2 pm) publicationDate (Document { publication_year: Just py, publication_month: Just pm, publication_day: Nothing }) =
publicationDate (Document { publication_year: Just py, publication_month: Just pm, publication_day: Just pd }) = (U.zeroPad 2 py) <> "-" <> (U.zeroPad 2 pm) <> "-" <> (U.zeroPad 2 pd) fold
[ U.zeroPad 2 py
, "-"
, U.zeroPad 2 pm
]
publicationDate
( Document
{ publication_year: Just py
, publication_month: Just pm
, publication_day: Just pd
, publication_hour: Nothing
}
) =
fold
[ U.zeroPad 2 py
, "-"
, U.zeroPad 2 pm
, "-"
, U.zeroPad 2 pd
]
publicationDate
( Document
{ publication_year: Just py
, publication_month: Just pm
, publication_day: Just pd
, publication_hour: Just phh
, publication_minute: Just pmm
, publication_second: Just pss
}
) =
fold
[ U.zeroPad 2 py
, "-"
, U.zeroPad 2 pm
, "-"
, U.zeroPad 2 pd
, " "
, U.zeroPad 2 phh
, ":"
, U.zeroPad 2 pmm
, ":"
, U.zeroPad 2 pss
]
publicationDate d = unsafeCrashWith $ "I don't know how to show publicationDate " <> show d
getIdName :: String -> String getIdName :: String -> String
getIdName str = "annotated-field-expand__" <> str getIdName str = "annotated-field-expand__" <> str
...@@ -70,12 +70,12 @@ newtype DocumentV3 = ...@@ -70,12 +70,12 @@ newtype DocumentV3 =
, language_iso3 :: Maybe String , language_iso3 :: Maybe String
, language_name :: Maybe String , language_name :: Maybe String
, publication_date :: Maybe String , publication_date :: Maybe String
, publication_year :: Maybe Int
, publication_month :: Maybe Int
, publication_day :: Maybe Int , publication_day :: Maybe Int
, publication_hour :: Maybe Int , publication_hour :: Maybe Int
, publication_minute :: Maybe Int , publication_minute :: Maybe Int
, publication_month :: Maybe Int
, publication_second :: Maybe Int , publication_second :: Maybe Int
, publication_year :: Maybe Int
, realdate_full_ :: Maybe String , realdate_full_ :: Maybe String
, source :: Maybe String , source :: Maybe String
, statuses :: Maybe (Array Status) , statuses :: Maybe (Array Status)
...@@ -95,12 +95,12 @@ newtype Document = ...@@ -95,12 +95,12 @@ newtype Document =
, language_iso2 :: Maybe String , language_iso2 :: Maybe String
-- , page :: Maybe Int -- , page :: Maybe Int
, publication_date :: Maybe String , publication_date :: Maybe String
--, publication_second :: Maybe Int
--, publication_minute :: Maybe Int
--, publication_hour :: Maybe Int
, publication_day :: Maybe Int
, publication_month :: Maybe Int
, publication_year :: Maybe Int , publication_year :: Maybe Int
, publication_month :: Maybe Int
, publication_day :: Maybe Int
, publication_hour :: Maybe Int
, publication_minute :: Maybe Int
, publication_second :: Maybe Int
, source :: Maybe String , source :: Maybe String
, institutes :: Maybe String , institutes :: Maybe String
, title :: Maybe String , title :: Maybe String
...@@ -141,12 +141,12 @@ defaultDocument = ...@@ -141,12 +141,12 @@ defaultDocument =
, language_iso2: Nothing , language_iso2: Nothing
--, page : Nothing --, page : Nothing
, publication_date: Nothing , publication_date: Nothing
--, publication_second : Nothing
--, publication_minute : Nothing
--, publication_hour : Nothing
, publication_day: Nothing
, publication_month: Nothing
, publication_year: Nothing , publication_year: Nothing
, publication_month: Nothing
, publication_day: Nothing
, publication_hour: Nothing
, publication_minute: Nothing
, publication_second: Nothing
, source: Nothing , source: Nothing
, institutes: Nothing , institutes: Nothing
, title: Nothing , title: Nothing
......
...@@ -94,6 +94,7 @@ data TimeUnit ...@@ -94,6 +94,7 @@ data TimeUnit
| Week TimeUnitCriteria | Week TimeUnitCriteria
| Day TimeUnitCriteria | Day TimeUnitCriteria
| Hour TimeUnitCriteria | Hour TimeUnitCriteria
| Minute TimeUnitCriteria
derive instance Generic TimeUnit _ derive instance Generic TimeUnit _
derive instance Eq TimeUnit derive instance Eq TimeUnit
...@@ -111,6 +112,7 @@ instance JSON.WriteForeign TimeUnit where ...@@ -111,6 +112,7 @@ instance JSON.WriteForeign TimeUnit where
Week (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseWeek) o Week (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseWeek) o
Day (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseDay) o Day (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseDay) o
Hour (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseHour) o Hour (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseHour) o
Minute (TimeUnitCriteria o) -> (JSON.writeImpl <<< parseMinute) o
where where
parseEpoch = parseEpoch =
Record.rename Record.rename
...@@ -190,6 +192,19 @@ instance JSON.WriteForeign TimeUnit where ...@@ -190,6 +192,19 @@ instance JSON.WriteForeign TimeUnit where
>>> Record.insert >>> Record.insert
(Proxy :: Proxy "tag") (Proxy :: Proxy "tag")
"Hour" "Hour"
parseMinute =
Record.rename
(Proxy :: Proxy "period")
(Proxy :: Proxy "_minute_period")
>>> Record.rename
(Proxy :: Proxy "step")
(Proxy :: Proxy "_minute_step")
>>> Record.rename
(Proxy :: Proxy "matchingFrame")
(Proxy :: Proxy "_minute_matchingFrame")
>>> Record.insert
(Proxy :: Proxy "tag")
"Minute"
data ReflexiveTimeUnit data ReflexiveTimeUnit
= Epoch_ = Epoch_
...@@ -198,6 +213,7 @@ data ReflexiveTimeUnit ...@@ -198,6 +213,7 @@ data ReflexiveTimeUnit
| Week_ | Week_
| Day_ | Day_
| Hour_ | Hour_
| Minute_
derive instance Generic ReflexiveTimeUnit _ derive instance Generic ReflexiveTimeUnit _
derive instance Eq ReflexiveTimeUnit derive instance Eq ReflexiveTimeUnit
...@@ -213,6 +229,7 @@ instance Read ReflexiveTimeUnit where ...@@ -213,6 +229,7 @@ instance Read ReflexiveTimeUnit where
"Week_" -> Just Week_ "Week_" -> Just Week_
"Day_" -> Just Day_ "Day_" -> Just Day_
"Hour_" -> Just Hour_ "Hour_" -> Just Hour_
"Minute_" -> Just Minute_
_ -> Nothing _ -> Nothing
newtype TimeUnitCriteria = TimeUnitCriteria newtype TimeUnitCriteria = TimeUnitCriteria
...@@ -320,6 +337,7 @@ toReflexiveTimeUnit (Month _) = Month_ ...@@ -320,6 +337,7 @@ toReflexiveTimeUnit (Month _) = Month_
toReflexiveTimeUnit (Week _) = Week_ toReflexiveTimeUnit (Week _) = Week_
toReflexiveTimeUnit (Day _) = Day_ toReflexiveTimeUnit (Day _) = Day_
toReflexiveTimeUnit (Hour _) = Hour_ toReflexiveTimeUnit (Hour _) = Hour_
toReflexiveTimeUnit (Minute _) = Minute_
fromReflexiveTimeUnit :: ReflexiveTimeUnit -> TimeUnitCriteria -> TimeUnit fromReflexiveTimeUnit :: ReflexiveTimeUnit -> TimeUnitCriteria -> TimeUnit
fromReflexiveTimeUnit Epoch_ c = Epoch c fromReflexiveTimeUnit Epoch_ c = Epoch c
...@@ -328,6 +346,7 @@ fromReflexiveTimeUnit Month_ c = Month c ...@@ -328,6 +346,7 @@ fromReflexiveTimeUnit Month_ c = Month c
fromReflexiveTimeUnit Week_ c = Week c fromReflexiveTimeUnit Week_ c = Week c
fromReflexiveTimeUnit Day_ c = Day c fromReflexiveTimeUnit Day_ c = Day c
fromReflexiveTimeUnit Hour_ c = Hour c fromReflexiveTimeUnit Hour_ c = Hour c
fromReflexiveTimeUnit Minute_ c = Minute c
extractCriteria :: TimeUnit -> TimeUnitCriteria extractCriteria :: TimeUnit -> TimeUnitCriteria
extractCriteria (Epoch (o :: TimeUnitCriteria)) = o extractCriteria (Epoch (o :: TimeUnitCriteria)) = o
...@@ -336,6 +355,7 @@ extractCriteria (Month (o :: TimeUnitCriteria)) = o ...@@ -336,6 +355,7 @@ extractCriteria (Month (o :: TimeUnitCriteria)) = o
extractCriteria (Week (o :: TimeUnitCriteria)) = o extractCriteria (Week (o :: TimeUnitCriteria)) = o
extractCriteria (Day (o :: TimeUnitCriteria)) = o extractCriteria (Day (o :: TimeUnitCriteria)) = o
extractCriteria (Hour (o :: TimeUnitCriteria)) = o extractCriteria (Hour (o :: TimeUnitCriteria)) = o
extractCriteria (Minute (o :: TimeUnitCriteria)) = o
toReflexiveClique :: Clique -> ReflexiveClique toReflexiveClique :: Clique -> ReflexiveClique
toReflexiveClique (FIS _) = FIS_ toReflexiveClique (FIS _) = FIS_
......
...@@ -198,6 +198,9 @@ component = R.hooksComponent "configForm" cpt ...@@ -198,6 +198,9 @@ component = R.hooksComponent "configForm" cpt
, H.option , H.option
{ value: show Hour_ } { value: show Hour_ }
[ H.text "Hour" ] [ H.text "Hour" ]
, H.option
{ value: show Minute_ }
[ H.text "Minute" ]
] ]
] ]
] ]
......
...@@ -368,6 +368,11 @@ data TimeUnit ...@@ -368,6 +368,11 @@ data TimeUnit
, _hour_step :: Int , _hour_step :: Int
, _hour_matchingFrame :: Int , _hour_matchingFrame :: Int
} }
| Minute
{ _minute_period :: Int
, _minute_step :: Int
, _minute_matchingFrame :: Int
}
derive instance Generic TimeUnit _ derive instance Generic TimeUnit _
derive instance Eq TimeUnit derive instance Eq TimeUnit
......
...@@ -179,3 +179,9 @@ detailsTimeUnit t = ...@@ -179,3 +179,9 @@ detailsTimeUnit t =
, detailsParams _hour_step "Step" , detailsParams _hour_step "Step"
, detailsParams _hour_matchingFrame "Matching frame" , detailsParams _hour_matchingFrame "Matching frame"
] ]
parseTimeUnit (Minute { _minute_period, _minute_step, _minute_matchingFrame }) =
[ detailsParams "Minute" "Time unit"
, detailsParams _minute_period "Period"
, detailsParams _minute_step "Step"
, detailsParams _minute_matchingFrame "Matching frame"
]
...@@ -22,9 +22,9 @@ export function yearToDate(year) { ...@@ -22,9 +22,9 @@ export function yearToDate(year) {
* @returns {Date} * @returns {Date}
*/ */
export function monthToDate(month) { export function monthToDate(month) {
var d = dayjs('0001-01-01'); var d = dayjs('0001-01-01T00:00:00Z');
return d.add(month, 'months').toDate(); return d.add(month, 'months').toDate();
} }
/** /**
* @name weekToDate * @name weekToDate
...@@ -33,7 +33,7 @@ export function monthToDate(month) { ...@@ -33,7 +33,7 @@ export function monthToDate(month) {
*/ */
export function weekToDate(week) { export function weekToDate(week) {
// week is number of days divided by 7 // week is number of days divided by 7
var d = dayjs('0001-01-01'); var d = dayjs('0001-01-01T00:00:00Z');
return d.add(week*7, 'days').toDate(); return d.add(week*7, 'days').toDate();
} }
...@@ -43,8 +43,7 @@ export function weekToDate(week) { ...@@ -43,8 +43,7 @@ export function weekToDate(week) {
* @returns {Date} * @returns {Date}
*/ */
export function dayToDate(days) { export function dayToDate(days) {
// week is number of days divided by 7 var d = dayjs('0001-01-01T00:00:00Z');
var d = dayjs('0001-01-01');
return d.add(days, 'days').toDate(); return d.add(days, 'days').toDate();
} }
...@@ -54,11 +53,20 @@ export function dayToDate(days) { ...@@ -54,11 +53,20 @@ export function dayToDate(days) {
* @returns {Date} * @returns {Date}
*/ */
export function hourToDate(hours) { export function hourToDate(hours) {
// week is number of days divided by 7 var d = dayjs('0001-01-01T00:00:00Z');
var d = dayjs('0001-01-01');
return d.add(hours, 'hours').toDate(); return d.add(hours, 'hours').toDate();
} }
/**
* @name minuteToDate
* @param {string} year
* @returns {Date}
*/
export function minuteToDate(minutes) {
var d = dayjs('0001-01-01T00:00:00Z');
return d.add(minutes, 'minutes').toDate();
}
/** /**
* @name stringToDate * @name stringToDate
* @param {string} str * @param {string} str
......
...@@ -39,7 +39,6 @@ import Data.String as String ...@@ -39,7 +39,6 @@ import Data.String as String
import Data.String.Extra (camelCase) import Data.String.Extra (camelCase)
import Data.Tuple as Tuple import Data.Tuple as Tuple
import Data.Tuple.Nested ((/\)) import Data.Tuple.Nested ((/\))
import Debug (trace)
import Gargantext.Components.PhyloExplorer.JSON (Cluster, PhyloJSON(..), PhyloSimilarity(..), Quality(..), RawEdge(..), RawObject(..), Synchrony(..), TimeUnit(..)) import Gargantext.Components.PhyloExplorer.JSON (Cluster, PhyloJSON(..), PhyloSimilarity(..), Quality(..), RawEdge(..), RawObject(..), Synchrony(..), TimeUnit(..))
import Partial.Unsafe (unsafeCrashWith) import Partial.Unsafe (unsafeCrashWith)
import Simple.JSON as JSON import Simple.JSON as JSON
...@@ -50,6 +49,7 @@ foreign import monthToDate :: String -> Date.Date ...@@ -50,6 +49,7 @@ foreign import monthToDate :: String -> Date.Date
foreign import weekToDate :: String -> Date.Date foreign import weekToDate :: String -> Date.Date
foreign import dayToDate :: String -> Date.Date foreign import dayToDate :: String -> Date.Date
foreign import hourToDate :: String -> Date.Date foreign import hourToDate :: String -> Date.Date
foreign import minuteToDate :: String -> Date.Date
foreign import stringToDate :: String -> Date.Date foreign import stringToDate :: String -> Date.Date
foreign import utcStringToDate :: String -> Date.Date foreign import utcStringToDate :: String -> Date.Date
...@@ -278,7 +278,7 @@ parseGroups tu epoch = map parse ...@@ -278,7 +278,7 @@ parseGroups tu epoch = map parse
, x: Tuple.fst $ parsePos o.pos , x: Tuple.fst $ parsePos o.pos
, y: Tuple.snd $ parsePos o.pos , y: Tuple.snd $ parsePos o.pos
} }
parse g = trace ("not a GroupToNode: " <> show g) \_ -> Nothing parse _ = Nothing
----------------------------------------------------------- -----------------------------------------------------------
...@@ -475,6 +475,7 @@ parseNodeDate (Month _) _ s _ = monthToDate (s) ...@@ -475,6 +475,7 @@ parseNodeDate (Month _) _ s _ = monthToDate (s)
parseNodeDate (Week _) _ s _ = weekToDate (s) parseNodeDate (Week _) _ s _ = weekToDate (s)
parseNodeDate (Day _) _ s _ = dayToDate (s) parseNodeDate (Day _) _ s _ = dayToDate (s)
parseNodeDate (Hour _) _ s _ = hourToDate (s) parseNodeDate (Hour _) _ s _ = hourToDate (s)
parseNodeDate (Minute _) _ s _ = minuteToDate (s)
parseNodeDate tu _ s _ = unsafeCrashWith $ "[parseNodeDate] s = " <> s <> " unsupported for time unit = " <> show tu parseNodeDate tu _ s _ = unsafeCrashWith $ "[parseNodeDate] s = " <> s <> " unsupported for time unit = " <> show tu
parsePos :: String -> Tuple.Tuple Number Number parsePos :: String -> Tuple.Tuple Number Number
......
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