<commit_before>module Gen.Logs exposing (..)

import Random.Pcg as Random
    exposing
        ( Generator
        , constant
        , map
        , map3
        , choices
        , andThen
        , list
        )
import Fuzz exposing (Fuzzer)
import Gen.Utils exposing (..)
import Game.Servers.Logs.Models exposing (..)


--------------------------------------------------------------------------------
-- Fuzzers
--------------------------------------------------------------------------------


logID : Fuzzer LogID
logID =
    fuzzer genLogID


logContent : Fuzzer LogContent
logContent =
    fuzzer genLogContent


logEntry : Fuzzer Log
logEntry =
    fuzzer genLogEntry


noLog : Fuzzer Log
noLog =
    fuzzer genNoLog


log : Fuzzer Log
log =
    fuzzer genLog


logList : Fuzzer (List Log)
logList =
    fuzzer genLogList


emptyLogs : Fuzzer Logs
emptyLogs =
    fuzzer genEmptyLogs


nonEmptyLogs : Fuzzer Logs
nonEmptyLogs =
    fuzzer genNonEmptyLogs


logs : Fuzzer Logs
logs =
    fuzzer genLogs


model : Fuzzer Logs
model =
    fuzzer genModel



--------------------------------------------------------------------------------
-- Generators
--------------------------------------------------------------------------------


genLogID : Generator LogID
genLogID =
    unique


genLogContent : Generator LogContent
genLogContent =
    stringRange 0 32


genLogData : Generator LogData
genLogData =
    map3
        LogData
        genLogID
        genLogContent
        genTimestamp


genLogEntry : Generator Log
genLogEntry =
    map LogEntry genLogData


genNoLog : Generator Log
genNoLog =
    constant NoLog


genLog : Generator Log
genLog =
    choices [ genLogEntry, genNoLog ]


genLogList : Generator (List Log)
genLogList =
    andThen (\num -> list num genLog) (Random.int 1 64)


genEmptyLogs : Generator Logs
genEmptyLogs =
    constant initialLogs


genNonEmptyLogs : Generator Logs
genNonEmptyLogs =
    andThen ((List.foldl (flip addLog) initialLogs) >> constant) genLogList


genLogs : Generator Logs
genLogs =
    choices [ genEmptyLogs, genNonEmptyLogs ]


genModel : Generator Logs
genModel =
    genNonEmptyLogs


genTimestamp : Generator LogTimestamp
genTimestamp =
    Random.float 1420070400 4102444799
<commit_msg>Update Gen.Log code style and reduce generated log list.<commit_after>module Gen.Logs exposing (..)

import Fuzz exposing (Fuzzer)
import Random.Pcg
    exposing
        ( Generator
        , constant
        , map
        , map3
        , choices
        , andThen
        , list
        , int
        , float
        )
import Gen.Utils exposing (..)
import Game.Servers.Logs.Models exposing (..)


--------------------------------------------------------------------------------
-- Fuzzers
--------------------------------------------------------------------------------


logID : Fuzzer LogID
logID =
    fuzzer genLogID


logContent : Fuzzer LogContent
logContent =
    fuzzer genLogContent


logEntry : Fuzzer Log
logEntry =
    fuzzer genLogEntry


noLog : Fuzzer Log
noLog =
    fuzzer genNoLog


log : Fuzzer Log
log =
    fuzzer genLog


logList : Fuzzer (List Log)
logList =
    fuzzer genLogList


emptyLogs : Fuzzer Logs
emptyLogs =
    fuzzer genEmptyLogs


nonEmptyLogs : Fuzzer Logs
nonEmptyLogs =
    fuzzer genNonEmptyLogs


logs : Fuzzer Logs
logs =
    fuzzer genLogs


model : Fuzzer Logs
model =
    fuzzer genModel



--------------------------------------------------------------------------------
-- Generators
--------------------------------------------------------------------------------


genLogID : Generator LogID
genLogID =
    unique


genLogContent : Generator LogContent
genLogContent =
    stringRange 0 32


genLogData : Generator LogData
genLogData =
    map3
        LogData
        genLogID
        genLogContent
        genTimestamp


genLogEntry : Generator Log
genLogEntry =
    map LogEntry genLogData


genNoLog : Generator Log
genNoLog =
    constant NoLog


genLog : Generator Log
genLog =
    choices [ genLogEntry, genNoLog ]


genLogList : Generator (List Log)
genLogList =
    andThen (genLog |> flip list) (int 1 10)


genEmptyLogs : Generator Logs
genEmptyLogs =
    constant initialLogs


genNonEmptyLogs : Generator Logs
genNonEmptyLogs =
    andThen ((List.foldl (flip addLog) initialLogs) >> constant) genLogList


genLogs : Generator Logs
genLogs =
    choices [ genEmptyLogs, genNonEmptyLogs ]


genModel : Generator Logs
genModel =
    genNonEmptyLogs


genTimestamp : Generator LogTimestamp
genTimestamp =
    float 1420070400 4102444799

{'fraction_non_alphanumeric': 0.18778827146936086, 'fraction_numerical': 0.012299582692730068, 'mean_word_length': 1.7236842105263157, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '4780138', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1330, 'n_words': 363}