<commit_before>module Pages.Ops exposing (..)

import Date exposing (Date)
import RemoteData exposing (RemoteData(..), WebData)
import I18n
import RemoteData.Http as Http
import Html exposing (..)
import Html.Attributes exposing (href, src)
import Html.Events exposing (..)
import Json.Decode exposing (..)

import Styles exposing (..)
import Types exposing (TacoUpdate(..), Taco, Person, People, Commit, Stargazer)
import Decoders
import Bootstrap.Button as Button

type alias Model =
    { commits : WebData (List Commit)
    , stargazers : WebData (List Stargazer)
    , people : WebData (People)
    }


type Msg
    = HandleCommits (WebData (List Commit))
    | HandleStargazers (WebData (List Stargazer))
    | HandlePeople (WebData (People))
    | ReloadData


init : ( Model, Cmd Msg )
init =
    ( { commits = Loading
      , stargazers = Loading
      , people = Loading
      }
    , fetchData
    )


fetchData : Cmd Msg
fetchData =
    Cmd.batch
        [ fetchCommits
        , fetchStargazers
        , fetchPeople
        ]

get : String -> (WebData success -> Msg) -> Json.Decode.Decoder success -> Cmd Msg
get =
    Http.getWithConfig Http.defaultConfig


fetchCommits : Cmd Msg
fetchCommits =
    get "https://api.github.com/repos/Numberartificial/cibops/commits"
        HandleCommits
        Decoders.decodeCommitList


fetchStargazers : Cmd Msg
fetchStargazers =
    get "https://api.github.com/repos/Numberartificial/cibops/stargazers"
        HandleStargazers
        Decoders.decodeStargazerList

fetchPeople : Cmd Msg
fetchPeople =
    get "http://172.16.31.10:8099/aic/api/people"
        HandlePeople
        Decoders.decodePeople


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        ReloadData ->
            ( { model<commit_msg>服务端接口加了CORS，可以拿到数据了，OH YEAH<commit_after>module Pages.Ops exposing (..)

import Date exposing (Date)
import RemoteData exposing (RemoteData(..), WebData)
import I18n
import RemoteData.Http as Http
import Html exposing (..)
import Html.Attributes exposing (href, src)
import Html.Events exposing (..)
import Json.Decode exposing (..)

import Styles exposing (..)
import Types exposing (TacoUpdate(..), Taco, Person, People, Commit, Stargazer)
import Decoders
import Bootstrap.Button as Button

type alias Model =
    { commits : WebData (List Commit)
    , stargazers : WebData (List Stargazer)
    , people : WebData (People)
    }


type Msg
    = HandleCommits (WebData (List Commit))
    | HandleStargazers (WebData (List Stargazer))
    | HandlePeople (WebData (People))
    | ReloadData


init : ( Model, Cmd Msg )
init =
    ( { commits = Loading
      , stargazers = Loading
      , people = Loading
      }
    , fetchData
    )


fetchData : Cmd Msg
fetchData =
    Cmd.batch
        [ fetchCommits
        , fetchStargazers
        , fetchPeople
        ]

get : String -> (WebData success -> Msg) -> Json.Decode.Decoder success -> Cmd Msg
get =
    Http.getWithConfig Http.defaultConfig


fetchCommits : Cmd Msg
fetchCommits =
    get "https://api.github.com/repos/Numberartificial/cibops/commits"
        HandleCommits
        Decoders.decodeCommitList


fetchStargazers : Cmd Msg
fetchStargazers =
    get "https://api.github.com/repos/Numberartificial/cibops/stargazers"
        HandleStargazers
        Decoders.decodeStargazerList

fetchPeople : Cmd Msg
fetchPeople =
    get "http://172.16.31.10:8099/aic/api/people"

    -- get "http://localhost:8099/aic/api/people"
        HandlePeople
        Decoders.decodePeople


update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
    case msg of
        ReloadData ->
            ( { model
{'fraction_non_alphanumeric': 0.09986320109439124, 'fraction_numerical': 0.009302325581395349, 'mean_word_length': 2.844374342797056, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '3259391', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1170, 'n_words': 298}