ogma
ogma copied to clipboard
[BUG] Variable not working through def
Current Behaviour
This works:
open wallet-lt.csv | filter timestamp { take 10 | >= $cutoff-date }
| let {nth 0 get:Num fiat-value} $start
{last get:Num fiat-value} $end
| Table $name
| append-row { \$end | - $start }
| append-row { \$end | / $start | - 1 }
| let $t
| open executions-lt.csv | filter timestamp { take 10 | >= $cutoff-date }
| filter real = 'true'
| append --ret-val { let #i.buy-fiat:Num $s | get sell-fiat | - $s }
| grp coin
| append --sum { get value | fold 0 {:Num + $row.ret-val } }
| sort 'sum'
| let $cs
| \$t
| append-row { \ $cs | if {empty} '' { last get:Str key } }
}
However, if we abstract the last line into a definition:
def def-if-empty (t:Table d e:Expr) { \ $t | if {empty} $d $e }
def summary-col (name:Str cutoff-date:Str) {
open wallet-lt.csv | filter timestamp { take 10 | >= $cutoff-date }
| let {nth 0 get:Num fiat-value} $start
{last get:Num fiat-value} $end
| Table $name
| append-row { \$end | - $start }
| append-row { \$end | / $start | - 1 }
| let $t
| open executions-lt.csv | filter timestamp { take 10 | >= $cutoff-date }
| filter real = 'true'
| append --ret-val { let #i.buy-fiat:Num $s | get sell-fiat | - $s }
| grp coin
| append --sum { get value | fold 0 {:Num + $row.ret-val } }
| sort 'sum'
| let $cs
| \$t
| append-row def-if-empty $cs '' { last get:Str key }
}
There is a runtime error saying that the column key
is not present.
This is either a locals issue or an input issue, but the last
call is not being invoked on the correct table.