Skip to content

Commit

Permalink
Merge pull request #1449 from stakwork/feat/stats_backend_connect
Browse files Browse the repository at this point in the history
Feat/stats backend connect
  • Loading branch information
elraphty authored Jan 23, 2024
2 parents e5d0494 + 40bfeb6 commit a10298f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand All @@ -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)
}

Expand Down
5 changes: 3 additions & 2 deletions db/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion db/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit a10298f

Please sign in to comment.