diff --git a/db/db.go b/db/db.go index b52060f23..e0e0c01dc 100644 --- a/db/db.go +++ b/db/db.go @@ -595,7 +595,7 @@ func (db database) GetAssignedBounties(r *http.Request) ([]Bounty, error) { } else { orderQuery = " ORDER BY paid DESC" } - if offset != 0 && limit != 0 { + if offset >= 0 && limit != 0 { limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset) } @@ -615,12 +615,12 @@ func (db database) GetCreatedBounties(r *http.Request) ([]Bounty, error) { limitQuery := "" if sortBy != "" && direction != "" { - orderQuery = "ORDER BY " + sortBy + " " + "ASC" + orderQuery = "ORDER BY " + sortBy + " " + direction } else { - orderQuery = "ORDER BY paid DESC" + orderQuery = "ORDER BY paid ASC" } - if offset != 0 && limit != 0 { + if offset >= 0 && limit != 0 { limitQuery = fmt.Sprintf("LIMIT %d OFFSET %d", limit, offset) } diff --git a/db/metrics.go b/db/metrics.go index 6bab47ae3..0fadfc19f 100644 --- a/db/metrics.go +++ b/db/metrics.go @@ -2,9 +2,10 @@ package db import ( "fmt" - "github.com/stakwork/sphinx-tribes/utils" "math" "net/http" + + "github.com/stakwork/sphinx-tribes/utils" ) var SecondsToDateConversion = 60 * 60 * 24 @@ -58,7 +59,7 @@ func (db database) TotalPaidBounties(r PaymentDateRange) int64 { func (db database) TotalHuntersPaid(r PaymentDateRange) int64 { var count int64 - db.db.Model(&Bounty{}).Select("DISTINCT assignee").Where("created >= ?", r.StartDate).Where("created <= ?", r.EndDate).Count(&count) + db.db.Model(&Bounty{}).Select("DISTINCT assignee").Where("assignee != ''").Where("paid = ?", true).Where("created >= ?", r.StartDate).Where("created <= ?", r.EndDate).Count(&count) return count } diff --git a/db/structs.go b/db/structs.go index 0a46dd150..2fa05da91 100644 --- a/db/structs.go +++ b/db/structs.go @@ -448,7 +448,7 @@ type Organization struct { Budget uint `json:"budget,omitempty"` Website string `json:"website" validate:"omitempty,uri"` Github string `json:"github" validate:"omitempty,uri"` - Description string `json:"description" validate:"omitempty,lte=200"` + Description string `json:"description" validate:"omitempty,lte=120"` } type OrganizationShort struct {