<commit_before>module Update exposing
    ( init
    , update
    )

-------------------------
-- Internal dependencies
-------------------------
import Model exposing ( .. )
import QueryApi exposing ( requestQuery )

init : ( AppState, Cmd Msg )
init = ( AppState
    ""
    Nothing
    False
    Nothing
    Nothing
    , Cmd.none )

handleUpdateQueryString : String -> AppState -> ( AppState, Cmd Msg )
handleUpdateQueryString newQueryString state =
    if String.length( newQueryString ) == 1 then (
        { state | queryString = newQueryString, queryResult = Nothing },
        submitCandidateQuery newQueryString
    )
    else if String.length( newQueryString ) == 0 then (
        { state | queryString = newQueryString, candidates = Nothing },
        Cmd.none
    )
    else (
        { state | queryString = newQueryString, queryResult = Nothing },
        Cmd.none
    )

update : Msg -> AppState -> ( AppState, Cmd Msg )
update msg state =
    case msg of
        NoOp -> ( state, Cmd.none )
        UpdateQueryString newQueryString -> handleUpdateQueryString newQueryString state
        UpdateAndSubmit newQueryString -> (
            { state | queryString = newQueryString, isQuerying = True, queryResult = Nothing, queryError = Nothing, candidates = Nothing },
            submitQuery newQueryString
        )
        SubmitQuery -> (
            { state | isQuerying = True, queryResult = Nothing, queryError = Nothing, candidates = Nothing },
            submitQuery state.queryString
        )
        SubmitCandidateQuery -> (
            { state | isQuerying = True, candidates = Nothing, queryError = Nothing },<commit_msg>Reformat a bit<commit_after>module Update exposing
    ( init
    , update
    )

-------------------------
-- Internal dependencies
-------------------------
import Model exposing ( .. )
import QueryApi exposing ( requestQuery )

init : ( AppState, Cmd Msg )
init = ( AppState
    ""
    Nothing
    False
    Nothing
    Nothing
    , Cmd.none )

handleUpdateQueryString : String -> AppState -> ( AppState, Cmd Msg )
handleUpdateQueryString newQueryString state =
    if String.length( newQueryString ) == 1 then (
        { state | queryString = newQueryString, queryResult = Nothing },
        submitCandidateQuery newQueryString
    )
    else if String.length( newQueryString ) == 0 then (
        { state | queryString = newQueryString, candidates = Nothing },
        Cmd.none
    )
    else (
        { state | queryString = newQueryString, queryResult = Nothing },
        Cmd.none
    )

update : Msg -> AppState -> ( AppState, Cmd Msg )
update msg state =
    case msg of
        NoOp -> ( state, Cmd.none )
        UpdateQueryString newQueryString -> handleUpdateQueryString newQueryString state
        UpdateAndSubmit newQueryString -> (
            { state | queryString = newQueryString
            , isQuerying = True
            , queryResult = Nothing
            , queryError = Nothing
            , candidates = Nothing
            },
            submitQuery newQueryString
        )
        SubmitQuery -> (
            { state | isQuerying = True
            , queryResult = Nothing
            , queryError = Nothing
            , candidates = Nothing
            },
            submitQuery state.queryString
        )
        SubmitCandidateQuery -> (
            { state | isQuerying = True
            , candidates = Nothing
            , queryError = Nothing
            },
{'fraction_non_alphanumeric': 0.1072463768115942, 'fraction_numerical': 0.0011594202898550724, 'mean_word_length': 1.9345238095238095, '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': '3985415', 'n_tokens_mistral': 874, 'n_tokens_neox': 855, 'n_words': 242}