<commit_before>module App.TreeStatus.Api exposing (..)

import App.TreeStatus.Types
import Http
import Json.Decode as JsonDecode exposing ((:=))
import Json.Encode as JsonEncode
import RemoteData


encoderUpdateTree :
    { a
        | message_of_the_day : String
        , reason : String
        , remember : Bool
        , status : String
        , trees : List String
        , tags : List String
    }
    -> JsonEncode.Value
encoderUpdateTree data =
    JsonEncode.object
        [ ( "trees", JsonEncode.list (List.map JsonEncode.string data.trees) )
        , ( "status", JsonEncode.string data.status )
        , ( "reason", JsonEncode.string data.reason )
        , ( "tags", JsonEncode.list (List.map JsonEncode.string data.tags) )
        , ( "message_of_the_day", JsonEncode.string data.message_of_the_day )
        , ( "remember", JsonEncode.bool data.remember )
        ]


encoderUpdateTrees :
    { a
        | reason : String
        , remember : Bool
        , status : String
        , trees : List String
        , tags : List String
    }
    -> JsonEncode.Value
encoderUpdateTrees data =
    JsonEncode.object
        [ ( "trees", JsonEncode.list (List.map JsonEncode.string data.trees) )
        , ( "status", JsonEncode.string data.status )
        , ( "reason", JsonEncode.string data.reason )
        , ( "tags", JsonEncode.list (List.map JsonEncode.string data.tags) )
        , ( "remember", JsonEncode.bool data.remember )
        ]


encoderTree : App.TreeStatus.Types.Tree -> JsonEncode.Value
encoderTree tree =
    JsonEncode.object
        [ ( "tree", JsonEncode.string tree.name )
        , ( "status", JsonEncode.string tree.status )
        , ( "reason", JsonEncode.string tree.reason )
        , ( "message_of_the_day", JsonEncode.string tree.message_of_the_day )
        ]


encoderTreeNames : App.TreeStatus.Types.Trees -> JsonEncode.Value
encoderTreeNames trees =
    JsonEncode.list (List.map (\x -> JsonEncode.string x.name) trees)


decoderTrees : JsonDecode.Decoder App.TreeStatus.Types.Trees
decoderTrees =
    JsonDecode.list decoderTree


decoderTree : JsonDecode.Decoder App.TreeStatus.Types.Tree
decoderTree =
    JsonDecode.object4 App.TreeStatus.Types.Tree
        ("tree" := JsonDecode.string)
        ("status" := JsonDecode.string)
        ("reason" := JsonDecode.string)
        ("message_of_the_day" := JsonDecode.string)


decoderTreeLogs : JsonDecode.Decoder App.TreeStatus.Types.TreeLogs
decoderTreeLogs =
    JsonDecode.list decoderTreeLog


decoderTreeLog : JsonDecode.Decoder App.TreeStatus.Types.TreeLog
decoderTreeLog =
    JsonDecode.object6 App.TreeStatus.Types.TreeLog
        ("tree" := JsonDecode.string)
        ("when" := JsonDecode.string)
        ("who" := JsonDecode.string)
        ("status" := JsonDecode.string)
        ("reason" := JsonDecode.string)
        ("tags" := JsonDecode.list JsonDecode.string)


decoderRecentChanges : JsonDecode.Decoder (List App.TreeStatus.Types.RecentChange)
decoderRecentChanges =
    JsonDecode.list decoderRecentChange


decoderRecentChange : JsonDecode.Decoder App.TreeStatus.Types.RecentChange
decoderRecentChange =
    JsonDecode.object6 App.TreeStatus.Types.RecentChange
        ("id" := JsonDecode.int)
        ("trees" := JsonDecode.list JsonDecode.string)
        ("when" := JsonDecode.string)<commit_msg>releng_frontend: treestatus api changed<commit_after>module App.TreeStatus.Api exposing (..)

import App.TreeStatus.Types
import Http
import Json.Decode as JsonDecode exposing ((:=))
import Json.Encode as JsonEncode
import RemoteData


encoderUpdateTree :
    { a
        | message_of_the_day : String
        , reason : String
        , remember : Bool
        , status : String
        , trees : List String
        , tags : List String
    }
    -> JsonEncode.Value
encoderUpdateTree data =
    JsonEncode.object
        [ ( "trees", JsonEncode.list (List.map JsonEncode.string data.trees) )
        , ( "status", JsonEncode.string data.status )
        , ( "reason", JsonEncode.string data.reason )
        , ( "tags", JsonEncode.list (List.map JsonEncode.string data.tags) )
        , ( "message_of_the_day", JsonEncode.string data.message_of_the_day )
        , ( "remember", JsonEncode.bool data.remember )
        ]


encoderUpdateTrees :
    { a
        | reason : String
        , remember : Bool
        , status : String
        , trees : List String
        , tags : List String
    }
    -> JsonEncode.Value
encoderUpdateTrees data =
    JsonEncode.object
        [ ( "trees", JsonEncode.list (List.map JsonEncode.string data.trees) )
        , ( "status", JsonEncode.string data.status )
        , ( "reason", JsonEncode.string data.reason )
        , ( "tags", JsonEncode.list (List.map JsonEncode.string data.tags) )
        , ( "remember", JsonEncode.bool data.remember )
        ]


encoderTree : App.TreeStatus.Types.Tree -> JsonEncode.Value
encoderTree tree =
    JsonEncode.object
        [ ( "tree", JsonEncode.string tree.name )
        , ( "status", JsonEncode.string tree.status )
        , ( "reason", JsonEncode.string tree.reason )
        , ( "message_of_the_day", JsonEncode.string tree.message_of_the_day )
        ]


encoderTreeNames : App.TreeStatus.Types.Trees -> JsonEncode.Value
encoderTreeNames trees =
    JsonEncode.list (List.map (\x -> JsonEncode.string x.name) trees)


decoderTrees : JsonDecode.Decoder App.TreeStatus.Types.Trees
decoderTrees =
    JsonDecode.list decoderTree2
        |> JsonDecode.at [ "result" ]


decoderTree2 : JsonDecode.Decoder App.TreeStatus.Types.Tree
decoderTree2 =
    JsonDecode.object4 App.TreeStatus.Types.Tree
        ("tree" := JsonDecode.string)
        ("status" := JsonDecode.string)
        ("reason" := JsonDecode.string)
        ("message_of_the_day" := JsonDecode.string)


decoderTree : JsonDecode.Decoder App.TreeStatus.Types.Tree
decoderTree =
    JsonDecode.at [ "result" ] decoderTree2


decoderTreeLogs : JsonDecode.Decoder App.TreeStatus.Types.TreeLogs
decoderTreeLogs =
    JsonDecode.list decoderTreeLog
        |> JsonDecode.at [ "result" ]


decoderTreeLog : JsonDecode.Decoder App.TreeStatus.Types.TreeLog
decoderTreeLog =
    JsonDecode.object6 App.TreeStatus.Types.TreeLog
        ("tree" := JsonDecode.string)
        ("when" := JsonDecode.string)
        ("who" := JsonDecode.string)
        ("status" := JsonDecode.string)
        ("reason" := JsonDecode.string)
        ("tags" := JsonDecode.list JsonDecode.string)


decoderRecentChanges : JsonDecode.Decoder (List App.TreeStatus.Types.RecentChange)
decoderRecentChanges =
    JsonDecode.list decoderRecentChange
        |> JsonDecode.at [ "result" ]


decoderRecentChange : JsonDecode.Decoder App.TreeStatus.Types.RecentChange
decoderRecentChange =
    JsonDecode.object6 App.TreeStatus.Types.RecentChange
        ("id" := JsonDecode.int)
        ("trees" := JsonDecode.list JsonDecode.string)
        ("when" := JsonDecode.string)
{'fraction_non_alphanumeric': 0.11186685962373372, 'fraction_numerical': 0.001447178002894356, 'mean_word_length': 2.9178004535147393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '4661350', 'n_tokens_mistral': 2078, 'n_tokens_neox': 1975, 'n_words': 397}