Working on the lua migration script, mistyped some names : /
This commit is contained in:
@@ -10,7 +10,7 @@ local function printTable(t)
|
||||
if type(value) == "table" then
|
||||
printTable(value)
|
||||
else
|
||||
print(key, value)
|
||||
print(key, ":", value)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -42,19 +42,24 @@ if not expenses then
|
||||
end
|
||||
|
||||
for i = 1, #expenses do
|
||||
-- print "------------------------------------"
|
||||
local eJson = expenses[i].expense
|
||||
local e = json.decode(eJson)
|
||||
|
||||
if not isOwnerInShares(e) then
|
||||
-- Insert a share in the owner user into shares as 0.0
|
||||
goto continue
|
||||
end
|
||||
|
||||
if not isOwnerInPayments(e) then
|
||||
-- Insert a share in the owner user into shares as 0.0
|
||||
goto continue
|
||||
end
|
||||
|
||||
normalizedExpense = NormalizeShare(eJson)
|
||||
if eJson == normalizedExpense then
|
||||
print "This one needs to be updated"
|
||||
end
|
||||
|
||||
::continue::
|
||||
end
|
||||
|
||||
@@ -3,19 +3,23 @@ package expenses
|
||||
import (
|
||||
"encoding/json"
|
||||
mod "expenses/expenses/models"
|
||||
"log"
|
||||
|
||||
lua "github.com/yuin/gopher-lua"
|
||||
)
|
||||
|
||||
func (a *ExpensesApp) luaGetAllExpenses(L *lua.LState) int {
|
||||
log.Println("HERE")
|
||||
tx, err := a.DB.Begin()
|
||||
if err != nil {
|
||||
return returnWithError(L, err.Error())
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
log.Println("HERE 2")
|
||||
expenses, err := mod.GetAllExpenses(tx)
|
||||
|
||||
log.Println("HERE 2")
|
||||
tbl := L.NewTable()
|
||||
for _, e := range expenses {
|
||||
err := a.LoadExpensePayments(&e)
|
||||
@@ -28,7 +32,8 @@ func (a *ExpensesApp) luaGetAllExpenses(L *lua.LState) int {
|
||||
return returnWithError(L, err.Error())
|
||||
}
|
||||
|
||||
jsonData, err := json.Marshal(e)
|
||||
jsonData, err := json.Marshal(&e)
|
||||
log.Println(string(jsonData))
|
||||
|
||||
et := L.NewTable()
|
||||
et.RawSetString("expense", lua.LString(jsonData))
|
||||
|
||||
@@ -19,7 +19,7 @@ type Expense struct {
|
||||
Store Store `json:"Store"`
|
||||
Type Type `json:"Type"`
|
||||
Category Category `json:"Category"`
|
||||
Owner User `json:"User"`
|
||||
Owner User `json:"Owner"`
|
||||
Date int64 `json:"Date"`
|
||||
Payments []ExpensePayment `json:"Payments"`
|
||||
Shares []Share `json:"Shares"`
|
||||
|
||||
Reference in New Issue
Block a user