Skip to content

Commit

Permalink
added completed to bounties status
Browse files Browse the repository at this point in the history
  • Loading branch information
elraphty committed Apr 17, 2024
1 parent cfd4613 commit c94681f
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,12 @@ func (db database) GetBountiesCount(r *http.Request) int64 {
open := keys.Get("Open")
assingned := keys.Get("Assigned")
paid := keys.Get("Paid")
completed := keys.Get("Completed")

openQuery := ""
assignedQuery := ""
paidQuery := ""
completedQuery := ""

if open != "" && open == "true" {
openQuery = "AND assignee = '' AND paid != true"
Expand All @@ -537,6 +540,13 @@ func (db database) GetBountiesCount(r *http.Request) int64 {
assignedQuery = "AND assignee != '' AND paid = false"
}
}
if completed != "" && completed == "true" {
if open != "" && open == "true" {
completedQuery = "OR assignee != '' AND completed = true AND paid = false"
} else {
completedQuery = "AND assignee != '' AND completed = true AND paid = false"
}
}
if paid != "" && paid == "true" {
if open != "" && open == "true" || assingned != "" && assingned == "true" {
paidQuery = "OR paid = true"
Expand All @@ -550,7 +560,7 @@ func (db database) GetBountiesCount(r *http.Request) int64 {
var count int64

query := "SELECT COUNT(*) FROM bounty WHERE show != false"
allQuery := query + " " + openQuery + " " + assignedQuery + " " + paidQuery
allQuery := query + " " + openQuery + " " + assignedQuery + " " + completedQuery + " " + paidQuery
db.db.Raw(allQuery).Scan(&count)
return count
}
Expand Down Expand Up @@ -579,6 +589,7 @@ func (db database) GetWorkspaceBounties(r *http.Request, org_uuid string) []Boun
offset, limit, sortBy, direction, search := utils.GetPaginationParams(r)
open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
languages := keys.Get("languages")
languageArray := strings.Split(languages, ",")
Expand Down Expand Up @@ -614,6 +625,9 @@ func (db database) GetWorkspaceBounties(r *http.Request, org_uuid string) []Boun
if assingned == "true" {
statusConditions = append(statusConditions, "assignee != '' AND paid = false")
}
if completed == "true" {
statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false")
}
if paid == "true" {
statusConditions = append(statusConditions, "paid = true")
}
Expand Down Expand Up @@ -662,6 +676,7 @@ func (db database) GetWorkspaceBountiesCount(r *http.Request, org_uuid string) i
search := keys.Get("search")
open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
languages := keys.Get("languages")
languageArray := strings.Split(languages, ",")
Expand All @@ -682,6 +697,9 @@ func (db database) GetWorkspaceBountiesCount(r *http.Request, org_uuid string) i
if assingned == "true" {
statusConditions = append(statusConditions, "assignee != '' AND paid = false")
}
if completed == "true" {
statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false")
}
if paid == "true" {
statusConditions = append(statusConditions, "paid = true")
}
Expand Down Expand Up @@ -901,6 +919,7 @@ func (db database) GetPreviousBountyByCreated(r *http.Request) (uint, error) {

open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
languages := keys.Get("languages")
languageArray := strings.Split(languages, ",")
Expand All @@ -921,6 +940,9 @@ func (db database) GetPreviousBountyByCreated(r *http.Request) (uint, error) {
if assingned == "true" {
statusConditions = append(statusConditions, "assignee != '' AND paid = false")
}
if completed == "true" {
statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false")
}
if paid == "true" {
statusConditions = append(statusConditions, "paid = true")
}
Expand Down Expand Up @@ -963,6 +985,7 @@ func (db database) GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error

open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
languages := keys.Get("languages")
languageArray := strings.Split(languages, ",")
Expand All @@ -983,6 +1006,9 @@ func (db database) GetNextWorkspaceBountyByCreated(r *http.Request) (uint, error
if assingned == "true" {
statusConditions = append(statusConditions, "assignee != '' AND paid = false")
}
if completed == "true" {
statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false")
}
if paid == "true" {
statusConditions = append(statusConditions, "paid = true")
}
Expand Down Expand Up @@ -1025,6 +1051,7 @@ func (db database) GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, e

open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
languages := keys.Get("languages")
languageArray := strings.Split(languages, ",")
Expand All @@ -1045,6 +1072,9 @@ func (db database) GetPreviousWorkspaceBountyByCreated(r *http.Request) (uint, e
if assingned == "true" {
statusConditions = append(statusConditions, "assignee != '' AND paid = false")
}
if completed == "true" {
statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false")
}
if paid == "true" {
statusConditions = append(statusConditions, "paid = true")
}
Expand Down Expand Up @@ -1101,6 +1131,7 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {
offset, limit, sortBy, direction, search := utils.GetPaginationParams(r)
open := keys.Get("Open")
assingned := keys.Get("Assigned")
completed := keys.Get("Completed")
paid := keys.Get("Paid")
orgUuid := keys.Get("org_uuid")
languages := keys.Get("languages")
Expand Down Expand Up @@ -1135,6 +1166,9 @@ func (db database) GetAllBounties(r *http.Request) []Bounty {
if assingned == "true" {
statusConditions = append(statusConditions, "assignee != '' AND paid = false")
}
if completed == "true" {
statusConditions = append(statusConditions, "assignee != '' AND completed = true AND paid = false")
}
if paid == "true" {
statusConditions = append(statusConditions, "paid = true")
}
Expand Down

0 comments on commit c94681f

Please sign in to comment.