<commit_before>module User exposing (..)

import Http
import Json.Decode exposing (Decoder, string, list, bool, nullable)
import Json.Decode.Pipeline as P
import Json.Encode as JS
import Skill

type alias Extra =
  { first_name : String
  , nick_name : String
  , domains : List String
  , positions : List String
  }

type alias User =
  { name : String
  , description : String
  , primaryDomain : String
  , primaryPosition : String
  , domains : List Skill.Model
  , positions : List Skill.Model
  , profileCreated : Bool
  , extra : Maybe Extra
  }

type alias Model =
  { user : Maybe User
  , spinning : Bool
  }

init : Model
init =
  { user = Nothing
  , spinning = False
  }

userDecoder : Decoder User
userDecoder =
  P.decode User
    |> P.required "name" string
    |> P.required "description" string
    |> P.required "primary_domain" string
    |> P.required "primary_position" string
    |> P.required "domains" (list Skill.decoder)
    |> P.required "positions" (list Skill.decoder)
    |> P.required "profile_creation_consented" bool
    |> P.required "extra" (nullable userExtraDecoder)

encode : User -> JS.Value
encode user =
  JS.object
    [ ("name", JS.string user.name)
    , ("description", JS.string user.description)
    , ("primary_domain", JS.string user.primaryDomain)
    , ("primary_position", JS.string user.primaryPosition)
    , ("domains", JS.list (List.map Skill.encode user.domains) )
    , ("positions", JS.list (List.map Skill.encode user.positions) )
    , ("profile_creation_consented", JS.bool user.profileCreated)
    ]

userExtraDecoder : Decoder Extra
userExtraDecoder =
  P.decode Extra<commit_msg>User.extra from nullable to optional<commit_after>module User exposing (..)

import Http
import Json.Decode exposing (Decoder, string, list, bool, nullable)
import Json.Decode.Pipeline as P
import Json.Encode as JS
import Skill

type alias Extra =
  { first_name : String
  , nick_name : String
  , domains : List String
  , positions : List String
  }

type alias User =
  { name : String
  , description : String
  , primaryDomain : String
  , primaryPosition : String
  , domains : List Skill.Model
  , positions : List Skill.Model
  , profileCreated : Bool
  , extra : Maybe Extra
  }

type alias Model =
  { user : Maybe User
  , spinning : Bool
  }

init : Model
init =
  { user = Nothing
  , spinning = False
  }

userDecoder : Decoder User
userDecoder =
  P.decode User
    |> P.required "name" string
    |> P.required "description" string
    |> P.required "primary_domain" string
    |> P.required "primary_position" string
    |> P.required "domains" (list Skill.decoder)
    |> P.required "positions" (list Skill.decoder)
    |> P.required "profile_creation_consented" bool
    |> P.optional "extra" (Json.Decode.map Just userExtraDecoder) Nothing

encode : User -> JS.Value
encode user =
  JS.object
    [ ("name", JS.string user.name)
    , ("description", JS.string user.description)
    , ("primary_domain", JS.string user.primaryDomain)
    , ("primary_position", JS.string user.primaryPosition)
    , ("domains", JS.list (List.map Skill.encode user.domains) )
    , ("positions", JS.list (List.map Skill.encode user.positions) )
    , ("profile_creation_consented", JS.bool user.profileCreated)
    ]

userExtraDecoder : Decoder Extra
userExtraDecoder =
  P.decode Extra
{'fraction_non_alphanumeric': 0.11184407796101949, 'fraction_numerical': 0.0, 'mean_word_length': 3.4718498659517425, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4777849', 'n_tokens_mistral': 1048, 'n_tokens_neox': 1004, 'n_words': 291}