<commit_before>module Events.Servers.Processes exposing (Event(..), handler)

import Utils.Events exposing (Handler)


type Event
    = Changed


handler : String -> Handler Event
handler event json =
    case event of
        "changed" ->
            onChanged json

        _ ->
            Nothing



-- internals


onChanged : Handler Event
onChanged json =
    Just Changed<commit_msg>Add process conclusion event.<commit_after>module Events.Servers.Processes exposing (Event(..), handler)

import Utils.Events exposing (Handler, notify)
import Json.Decode
    exposing
        ( decodeValue
        , oneOf
        , map
        , maybe
        , lazy
        , list
        , string
        , int
        )
import Json.Decode.Pipeline exposing (decode, required, optional)
import Utils.Events exposing (Handler)


type Event
    = Changed
    | Conclusion String


handler : String -> Handler Event
handler event json =
    case event of
        "changed" ->
            onChanged json

        "conclusion" ->
            onConclusion json

        _ ->
            Nothing



-- internals


onChanged : Handler Event
onChanged json =
    Just Changed


onConclusion : Handler Event
onConclusion json =
    let
        decoder =
            decode identity
                |> required "process_id" string
    in
        decodeValue decoder json
            |> Result.map Conclusion
            |> notify
{'fraction_non_alphanumeric': 0.06945428773919206, 'fraction_numerical': 0.0, 'mean_word_length': 1.911340206185567, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3200956', 'n_tokens_mistral': 387, 'n_tokens_neox': 350, 'n_words': 116}