|
@@ -2,14 +2,16 @@ module LinkedIn.Profile.WorkExperience where
|
|
|
|
|
|
|
|
import Prelude
|
|
import Prelude
|
|
|
|
|
|
|
|
-import Data.Either (Either, note)
|
|
|
|
|
|
|
+import Data.Either (Either(..), note)
|
|
|
import Data.Foldable (findMap)
|
|
import Data.Foldable (findMap)
|
|
|
import Data.Generic.Rep (class Generic)
|
|
import Data.Generic.Rep (class Generic)
|
|
|
|
|
+import Data.List as L
|
|
|
import Data.Maybe (Maybe(..))
|
|
import Data.Maybe (Maybe(..))
|
|
|
import Data.Show.Generic (genericShow)
|
|
import Data.Show.Generic (genericShow)
|
|
|
|
|
+import Data.Traversable (traverse)
|
|
|
import LinkedIn.ArtDecoCard (ArtDecoCardElement, toCenterContent, toHeaderBold, toHeaderLight, toHeaderNormal)
|
|
import LinkedIn.ArtDecoCard (ArtDecoCardElement, toCenterContent, toHeaderBold, toHeaderLight, toHeaderNormal)
|
|
|
import LinkedIn.DetachedNode (DetachedNode)
|
|
import LinkedIn.DetachedNode (DetachedNode)
|
|
|
-import LinkedIn.Profile.Utils (maybeExtractFromMaybe, maybeFindInMaybeNEL, maybeGetInList, toUIElement)
|
|
|
|
|
|
|
+import LinkedIn.Profile.Utils (toUIElement)
|
|
|
import LinkedIn.UIElements.Types (Duration, TimeSpan, UIElement(..), UIString(..))
|
|
import LinkedIn.UIElements.Types (Duration, TimeSpan, UIElement(..), UIString(..))
|
|
|
|
|
|
|
|
data WorkExperience = WorkExperience {
|
|
data WorkExperience = WorkExperience {
|
|
@@ -27,23 +29,27 @@ instance Show WorkExperience where
|
|
|
show = genericShow
|
|
show = genericShow
|
|
|
|
|
|
|
|
fromUI ∷ ArtDecoCardElement DetachedNode → Either String WorkExperience
|
|
fromUI ∷ ArtDecoCardElement DetachedNode → Either String WorkExperience
|
|
|
-fromUI (card) = ado
|
|
|
|
|
- position <- note "No position found" $ findMap extractPosition bold
|
|
|
|
|
|
|
+fromUI card = fromUI' =<< case traverse toUIElement card of
|
|
|
|
|
+ Left _ -> Left "error on conversion to UI element"
|
|
|
|
|
+ Right ui -> Right ui
|
|
|
|
|
+
|
|
|
|
|
+fromUI' ∷ ArtDecoCardElement UIElement → Either String WorkExperience
|
|
|
|
|
+fromUI' card = ado
|
|
|
|
|
+ position <- note "No position found" $ extractPosition bold
|
|
|
in
|
|
in
|
|
|
WorkExperience {
|
|
WorkExperience {
|
|
|
position,
|
|
position,
|
|
|
- company: maybeExtractFromMaybe extractCompany normal,
|
|
|
|
|
- contractType: maybeExtractFromMaybe extractContractType normal,
|
|
|
|
|
- timeSpan: maybeFindInMaybeNEL extractTimeSpan light,
|
|
|
|
|
- duration: maybeFindInMaybeNEL extractDuration light,
|
|
|
|
|
- description: maybeGetInList extractDescription content 0
|
|
|
|
|
|
|
+ company: extractCompany =<< normal,
|
|
|
|
|
+ contractType: extractContractType =<< normal,
|
|
|
|
|
+ timeSpan: findMap extractTimeSpan =<< light,
|
|
|
|
|
+ duration: findMap extractDuration =<< light,
|
|
|
|
|
+ description: extractDescription =<< L.index content 0
|
|
|
}
|
|
}
|
|
|
where
|
|
where
|
|
|
- asUI = toUIElement <$> card
|
|
|
|
|
- normal = toHeaderNormal asUI
|
|
|
|
|
- light = toHeaderLight asUI
|
|
|
|
|
- content = toCenterContent asUI
|
|
|
|
|
- bold = toHeaderBold asUI
|
|
|
|
|
|
|
+ normal = toHeaderNormal card
|
|
|
|
|
+ light = toHeaderLight card
|
|
|
|
|
+ content = toCenterContent card
|
|
|
|
|
+ bold = toHeaderBold card
|
|
|
|
|
|
|
|
extractPosition :: UIElement -> Maybe String
|
|
extractPosition :: UIElement -> Maybe String
|
|
|
extractPosition = case _ of
|
|
extractPosition = case _ of
|