<commit_before>module Shared.User (..) where

import Json.Decode exposing (Value, Decoder, succeed, (:=), string, maybe, value, customDecoder)
import Json.Decode.Extra exposing (apply)
import String

import Converters exposing (deserialize)
import Moment exposing (Moment, emptyMoment)


(|:) =
    Json.Decode.Extra.apply


type alias User =
    { token : String
    , name : String
    , email : String
    , role : String
    , startTime : Maybe Moment
    , endTime : Maybe Moment
    , submissionLocation : Maybe Moment
    }


emptyUser =
    { token = ""
    , name = ""
    , email = ""
    , role = ""
    , startTime = Nothing
    , endTime = Nothing
    , submissionLocation = Nothing
    }


{-| Decode a Maybe Moment
-}
decodeMaybeMoment : Decoder (Maybe Moment)
decodeMaybeMoment =
    customDecoder value (\val -> Ok (deserialize val))


decoder : Decoder User
decoder =
    succeed User
        |: ("token" := string)
        |: ("name" := string)
        |: ("email" := string)
        |: ("role" := string)
        |: ("startTime" := decodeMaybeMoment)
        |: ("endTime" := decodeMaybeMoment)
        |: ("submissionLocation" := decodeMaybeMoment)


hasStartedTest : User -> Bool
hasStartedTest user =
    case user.startTime of
        Nothing ->
            False

        _ ->
            True<commit_msg>submissions should be a url<commit_after>module Shared.User (..) where

import Json.Decode exposing (Value, Decoder, succeed, (:=), string, maybe, value, customDecoder)
import Json.Decode.Extra exposing (apply)
import String

import Converters exposing (deserialize)
import Moment exposing (Moment, emptyMoment)


(|:) =
    Json.Decode.Extra.apply


type alias User =
    { token : String
    , name : String
    , email : String
    , role : String
    , startTime : Maybe Moment
    , endTime : Maybe Moment
    , submissionLocation : Maybe String
    }


emptyUser =
    { token = ""
    , name = ""
    , email = ""
    , role = ""
    , startTime = Nothing
    , endTime = Nothing
    , submissionLocation = Nothing
    }


{-| Decode a Maybe Moment
-}
decodeMaybeMoment : Decoder (Maybe Moment)
decodeMaybeMoment =
    customDecoder value (\val -> Ok (deserialize val))


decoder : Decoder User
decoder =
    succeed User
        |: ("token" := string)
        |: ("name" := string)
        |: ("email" := string)
        |: ("role" := string)
        |: ("startTime" := decodeMaybeMoment)
        |: ("endTime" := decodeMaybeMoment)
        |: ("submissionLocation" := maybe string)


hasStartedTest : User -> Bool
hasStartedTest user =
    case user.startTime of
        Nothing ->
            False

        _ ->
            True
{'fraction_non_alphanumeric': 0.12139378044211314, 'fraction_numerical': 0.0, 'mean_word_length': 2.485639686684073, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '5693587', 'n_tokens_mistral': 814, 'n_tokens_neox': 773, 'n_words': 216}