<commit_before>module Views.TransactionTable exposing (transactionTable)

import Date exposing (..)
import Date.Format exposing (format)
import Html exposing (..)
import Html.Attributes exposing (class)
import Models exposing (Model, Debt)
import Messages exposing (Msg(..))

transactionTable : List Debt -> Html Msg
transactionTable debts =
  table [ class "table table-striped table-condensed table-bordered" ]
    [ transactionTableHead
    , transactionList debts ]


transactionTableHead : Html Msg
transactionTableHead =
  thead []
    [ tr []
      [ th [] [ text "Date" ]
      , th [] [ text "Name" ]
      , th [] [ text "Debt" ]
      , th [] [ text "Description" ]
      ]
    ]


transactionList : List Debt -> Html Msg
transactionList debts =
  tbody []
    ( List.map transactionRow debts )


transactionRow : Debt -> Html Msg
transactionRow debt =
  tr []
    [ td [] [ text (formatTimestamp debt.created_at) ]
    , td [] [ text debt.receiver ]
    , td [] [ text ( toString debt.amount ) ]
    , td [] [ text debt.description ]
    ]

formatTimestamp : Int -> String
formatTimestamp timestamp =
  Date.fromTime (toFloat timestamp)
  |> format "%Y/%m/%d"
<commit_msg>Sort transactions by date desc<commit_after>module Views.TransactionTable exposing (transactionTable)

import Date exposing (..)
import Date.Format exposing (format)
import Html exposing (..)
import Html.Attributes exposing (class)
import Models exposing (Model, Debt)
import Messages exposing (Msg(..))

transactionTable : List Debt -> Html Msg
transactionTable debts =
  table [ class "table table-striped table-condensed table-bordered" ]
    [ transactionTableHead
    , transactionList debts ]


transactionTableHead : Html Msg
transactionTableHead =
  thead []
    [ tr []
      [ th [] [ text "Date" ]
      , th [] [ text "Name" ]
      , th [] [ text "Debt" ]
      , th [] [ text "Description" ]
      ]
    ]


transactionList : List Debt -> Html Msg
transactionList debts =
  tbody []
    ( List.sortBy .created_at debts
      |> List.reverse
      |> List.map transactionRow
    )

transactionRow : Debt -> Html Msg
transactionRow debt =
  tr []
    [ td [] [ text (formatTimestamp debt.created_at) ]
    , td [] [ text debt.receiver ]
    , td [] [ text ( toString debt.amount ) ]
    , td [] [ text debt.description ]
    ]

formatTimestamp : Int -> String
formatTimestamp timestamp =
  Date.fromTime (toFloat timestamp)
  |> format "%Y/%m/%d"

{'fraction_non_alphanumeric': 0.1174785100286533, 'fraction_numerical': 0.0, 'mean_word_length': 3.1006711409395975, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3843254', 'n_tokens_mistral': 757, 'n_tokens_neox': 709, 'n_words': 213}