Skip to content

Commit

Permalink
Merge pull request #1083 from stakwork/fix/track_history
Browse files Browse the repository at this point in the history
Fix/track history
  • Loading branch information
elraphty committed Dec 12, 2023
2 parents 37f84e9 + 852a62c commit 6e221e8
Show file tree
Hide file tree
Showing 3 changed files with 202 additions and 405 deletions.
20 changes: 4 additions & 16 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -1307,29 +1307,17 @@ func (db database) AddPaymentHistory(payment PaymentHistory) PaymentHistory {
return payment
}

func (db database) GetPaymentHistory(org_uuid string, p string, l string) []PaymentHistory {
func (db database) GetPaymentHistory(org_uuid string, r *http.Request) []PaymentHistory {
payment := []PaymentHistory{}

page := 0
limit := 0
offset, limit, _, _, _ := utils.GetPaginationParams(r)
limitQuery := ""

if p != "" {
page, _ = utils.ConvertStringToInt(p)
}

if l != "" {
limit, _ = utils.ConvertStringToInt(l)
}
limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset)

if page != 0 && limit != 0 {
limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, page)
}

query := `SELECT * FROM public.payment_histories WHERE org_uuid = '` + org_uuid + `' ORDER BY created DESC`
query := `SELECT * FROM payment_histories WHERE org_uuid = '` + org_uuid + `' ORDER BY created DESC`

db.db.Raw(query + " " + limitQuery).Find(&payment)

return payment
}

Expand Down
Loading

0 comments on commit 6e221e8

Please sign in to comment.